digitalmars.D.bugs - [Issue 1254] New: Using a parameter initialized to void in a compile-time evaluated function doesn't work
- d-bugmail puremagic.com (32/32) Jun 02 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1254
- d-bugmail puremagic.com (8/8) Jun 02 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1254
- d-bugmail puremagic.com (9/9) Jun 02 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1254
- d-bugmail puremagic.com (6/6) Jun 23 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1254
- d-bugmail puremagic.com (10/10) Jun 26 2007 http://d.puremagic.com/issues/show_bug.cgi?id=1254
http://d.puremagic.com/issues/show_bug.cgi?id=1254 Summary: Using a parameter initialized to void in a compile-time evaluated function doesn't work Product: D Version: 1.014 Platform: PC URL: http://www.digitalmars.com/d/function.html OS/Version: Windows Status: NEW Keywords: diagnostic, rejects-valid Severity: normal Priority: P3 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: deewiant gmail.com int foo() { int x = void; return bar(x); } int bar(int dummy) { return 1; } const i = foo(); The above results in "Error: variable x is used before initialization" without a file name or line number. The Functions page at http://www.digitalmars.com/d/function.html says only that use of uninitialized variables can give different results at compile time, but it doesn't disallow it. There are two bugs: first, the error message should have a file name and line number, and second, there should be no error message and the code should compile. --
Jun 02 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1254 ------- Comment #1 from bugzilla digitalmars.com 2007-06-02 12:52 ------- The compiler is allowed to issue errors for "use before initialized" problems, although it is not required to detect them. On a pragmatic note, I can't see anything good coming from supporting using the values of uninitialized variables in CTFE. The error message missing file/line info is still a bug, though. --
Jun 02 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1254 ------- Comment #2 from deewiant gmail.com 2007-06-02 13:02 ------- Well, there's no particular use for it in CTFE, but the thing is that a function may be used both with and without CTFE. In the latter case, not initializing a variable is an optimization (though in this case of a single integer it hardly matters), and may be useful. In the CTFE case, it might as well be initialized anyway, if that's easier: it's a bug to rely on the contents of uninitialized variables anyway. --
Jun 02 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1254 ------- Comment #3 from bugzilla digitalmars.com 2007-06-23 03:46 ------- The error message should have the file/line. But the code is erroneous - even though the uninitialized value is eventually unused, it is technically used when passed to bar(), and hence is illegal. --
Jun 23 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1254 deewiant gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #4 from deewiant gmail.com 2007-06-26 14:32 ------- Error message has a line number in DMD 1.017. Marking as FIXED, as it seems that's all I'll get. --
Jun 26 2007