[Issue 3809] Struct initializers apparently always CTFE'd, and incorrectly

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 31 11:46:39 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3809



--- Comment #4 from Don <clugdbug at yahoo.com.au> 2010-05-31 11:46:37 PDT ---
This isn't really a regression. Struct static initializers
have always been CTFEd, for example the code below generates a compile-time
div-by-zero error even in DMD 1.023. The only reason this code ever worked
was that CTFE didn't work for member functions. Starting with svn 337 
(DMD1.056), member functions can be called at compile time.

However, the spec says:
"The static initializer syntax can also be used to initialize non-static
variables, provided that the member names are not given. 
The initializer need not be evaluatable at compile time."

The compiler has never complied with this part of the spec.

// Should compile, but fails
int bug3809() { asm { nop; } return 0; }
struct BUG3809 { int xx; }
void bug3809b() {
    BUG3809 b = { bug3809() };
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list