digitalmars.D.bugs - [Issue 6551] New: [CTFE] struct constructor not recognized under weird conditions
- d-bugmail puremagic.com (46/46) Aug 24 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6551
- d-bugmail puremagic.com (24/24) Sep 01 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6551
http://d.puremagic.com/issues/show_bug.cgi?id=6551 Summary: [CTFE] struct constructor not recognized under weird conditions Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Keywords: rejects-valid Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: mrmocool gmx.de --- Comment #0 from Trass3r <mrmocool gmx.de> 2011-08-24 16:51:05 PDT --- So there's a struct with a ubyte. To shut up dmd about implicit conversions I added a constructor but it isn't recognized. // this failes immutable int dummy = init(); int init() { uint x; 6: auto p = F(x); return 0; } struct F { ubyte th; this(uint x) { th = cast(ubyte) x; } } // while it works in this case void main() { uint x; auto p = F(x); } $ dmd -c posecells.d DMD v2.055 DEBUG posecells.d(6): Error: cannot implicitly convert expression (x) of type uint to ubyte posecells.d(2): Error: cannot evaluate init() at compile time Weird thing is, if you remove 'int' in front of 'dummy' it magically works. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 24 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6551 Don <clugdbug yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugdbug yahoo.com.au Version|unspecified |D2 Summary|[CTFE] struct constructor |struct constructor not |not recognized under weird |recognized when forward |conditions |referenced --- Comment #1 from Don <clugdbug yahoo.com.au> 2011-09-01 04:30:48 PDT --- This isn't a CTFE bug. Reduced test case: uint NINE = 9; typeof(F(NINE)) fails; struct F { ubyte th; this(uint x) { th = cast(ubyte) x; } } This is a forward reference issue. It compiles if you move the declaration of 'fails' past the declaration of F. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 01 2011