digitalmars.D.bugs - [Issue 3160] New: ICE(cgcod.c 1511) returning string from void main, D1 only
- d-bugmail puremagic.com (19/19) Jul 10 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3160
- d-bugmail puremagic.com (15/15) Sep 14 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3160
- d-bugmail puremagic.com (31/31) Sep 15 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3160
- d-bugmail puremagic.com (43/43) Sep 15 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3160
- d-bugmail puremagic.com (6/6) Oct 01 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3160
- d-bugmail puremagic.com (12/12) Oct 06 2009 http://d.puremagic.com/issues/show_bug.cgi?id=3160
http://d.puremagic.com/issues/show_bug.cgi?id=3160 Summary: ICE(cgcod.c 1511) returning string from void main, D1 only Product: D Version: 1.045 Platform: Other OS/Version: Windows Status: NEW Keywords: ice-on-invalid-code Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: clugdbug yahoo.com.au Courtesy of bearophile. void main() { return "a"; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jul 10 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3160 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |regression This is actually a regression. Did not ICE in 0.175, 1.006. Began to ICE at 1.017 or earlier. ICE in 2.000->2.022. Was fixed in 2.023. However, although it didn't ICE on those versions, it's an accepts-invalid. Seems to be adding an implicitly cast to void. (BTW, the accepts-invalid applies to all functions, not just main). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 14 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3160 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |patch ROOT CAUSE: The logic for inserting a "return 0" at the end of a void main, and the logic for evaluating the return expression in a void function, interact incorrectly. The case where BOTH these things need to happen was missing. BTW, this is probably wrong in D2 as well. PATCH: statement.c, last lines of ReturnStatement::semantic (around line 2891): - if (exp && tbret->ty == Tvoid && !fd->isMain()) + if (exp && tbret->ty == Tvoid && !implicit0) { /* Replace: * return exp; * with: * exp; return; */ Statement *s = new ExpStatement(loc, exp); loc = 0; + if (fd->isMain()) exp = new IntegerExp(0); + else exp = NULL; return new CompoundStatement(loc, s, this); } return this; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 15 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3160 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords|ice-on-invalid-code |ice-on-valid-code Summary|ICE(cgcod.c 1511) returning |ICE(cgcod.c 1511-D1) or bad |string from void main, D1 |code-D2 returning string |only |from void main Severity|regression |critical In D2, rather than an ICE, it generates wrong code. Can't really claim ICE<->wrong-code is a regression. Technically, this is valid, but I'm actually not sure if this type of code should be allowed. Should it check for side-effects? IE, void main() { return 2; } --> should this generate a "expression (2) has no effect" error? Seems like a newbie trap. Here's a more formal patch against DMD2.032: Index: statement.c =================================================================== --- statement.c (revision 54) +++ statement.c (revision 55) -3454,7 +3454,7 return gs; } - if (exp && tbret->ty == Tvoid && !fd->isMain()) + if (exp && tbret->ty == Tvoid && !implicit0) { /* Replace: * return exp; -3463,7 +3463,10 */ Statement *s = new ExpStatement(loc, exp); loc = 0; - exp = NULL; + if (fd->isMain()) + exp = new IntegerExp(0); + else + exp = NULL; return new CompoundStatement(loc, s, this); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 15 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3160 The patch for the related bug 3344 adds a check for side-effects. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 01 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3160 Walter Bright <bugzilla digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |bugzilla digitalmars.com Resolution| |FIXED 02:17:15 PDT --- Fixed dmd 1.048 and 2.033 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 06 2009