digitalmars.D.bugs - [Issue 2350] New: Contracts with a naked body are indecent
- d-bugmail puremagic.com (29/29) Sep 09 2008 http://d.puremagic.com/issues/show_bug.cgi?id=2350
- d-bugmail puremagic.com (11/11) Sep 04 2011 http://d.puremagic.com/issues/show_bug.cgi?id=2350
- d-bugmail puremagic.com (31/33) Sep 05 2011 http://d.puremagic.com/issues/show_bug.cgi?id=2350
http://d.puremagic.com/issues/show_bug.cgi?id=2350 Summary: Contracts with a naked body are indecent Product: D Version: 1.034 Platform: PC OS/Version: Windows Status: NEW Keywords: wrong-code Severity: normal Priority: P4 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: clugdbug yahoo.com.au It seems that in/out contracts assume that a stack frame has been set up. This is not true for naked functions, so bad code is generated. Ideally, if the body contains the keyword 'naked', in/out contracts should create and destroy a stack frame. ---- void rude(int a) in { assert(a==1); } body { asm { naked; } } void main() { rude(1); } --
Sep 09 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2350 Stewart Gordon <smjg iname.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |smjg iname.com In which case, what would "naked" do? If nothing, the compiler ought to disallow it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 04 2011
http://d.puremagic.com/issues/show_bug.cgi?id=2350In which case, what would "naked" do? If nothing, the compiler ought to disallow it.For non-naked functions, the contracts don't set up a stack frame, because the function already does it. The generated code is: push EBP; mov EBP, ESP; <run in contract> <run function body> <run out contract> pop EBP; If no contracts are present, or with -release, the generated code is currently: <run naked body> which is correct. But if contracts are present, and not in a release build, the code is: <run in contract> <run naked body> <run out contract> which causes a crash. Correct behaviour would be: push EBP; mov EBP, ESP; <run in contract> pop EBP; <run naked body> push EBP; mov EBP, ESP; <run out contract> pop EBP; -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 05 2011