Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
March 28, 2011 [Issue 5790] New: "Error: variable result used before set" when -release -inline -O | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5790 Summary: "Error: variable result used before set" when -release -inline -O Product: D Version: D2 Platform: x86 OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: jordi@rovira.cat --- Comment #0 from Jordi Rovira i Bonet <jordi@rovira.cat> 2011-03-28 05:54:10 PDT --- When compiling the following code with dmd -c -release -inline -O resource.d I get the message "Error: variable result used before set" without any line information, and compilation fails. This happens only with the flags above. Removing any of them, or compiling in debug results in good output. I have verified that this error happens both in linux and windows, with dmd 2.052 and since many versions ago. <Speculation> Even GDC crashes compiling this code in release, which makes me think it is in the front end. <Data> I have removed everything i could, and now the code doesn't make much sense, but the file resource.d is: module bug; import std.c.string; class InputStream { public: InputStream opShr(T)( out T result ) { memcpy( &result, &m_data[m_pos], T.sizeof ); m_pos += T.sizeof; return this; } int m_pos; const ubyte[] m_data; } struct GUID { uint m_values[4]; }; struct Header { int ver; int siz; GUID id; } void LoadResourceLegacyHeader( InputStream f, out Header header ) { f >> header.id; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 28, 2011 [Issue 5790] "Error: variable result used before set" when -release -inline -O | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jordi Rovira i Bonet | http://d.puremagic.com/issues/show_bug.cgi?id=5790 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bearophile_hugs@eml.cc --- Comment #1 from bearophile_hugs@eml.cc 2011-03-28 10:13:29 PDT --- (In reply to comment #0) > I have removed everything i could, Reduced program: struct Foo { int x; int[3] y; } void baz(out int[3] y2) { y2[0]++; } void spam(out Foo f) { baz(f.y); } void main() {} -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 28, 2011 [Issue 5790] "Error: variable result used before set" when -release -inline -O | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jordi Rovira i Bonet | http://d.puremagic.com/issues/show_bug.cgi?id=5790 --- Comment #2 from Jordi Rovira i Bonet <jordi@rovira.cat> 2011-03-28 10:17:14 PDT --- (In reply to comment #1) > (In reply to comment #0) > > > I have removed everything i could, > > Reduced program: > > > struct Foo { > int x; > int[3] y; > } > void baz(out int[3] y2) { > y2[0]++; > } > void spam(out Foo f) { > baz(f.y); > } > void main() {} Thanks! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 28, 2011 [Issue 5790] "Error: variable result used before set" when -release -inline -O | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jordi Rovira i Bonet | http://d.puremagic.com/issues/show_bug.cgi?id=5790 bearophile_hugs@eml.cc changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |critical --- Comment #3 from bearophile_hugs@eml.cc 2011-03-28 10:18:41 PDT --- Critical, as per Don request. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 28, 2011 [Issue 5790] "Error: variable result used before set" when -release -inline -O | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jordi Rovira i Bonet | http://d.puremagic.com/issues/show_bug.cgi?id=5790 kennytm@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |kennytm@gmail.com --- Comment #4 from kennytm@gmail.com 2011-03-28 10:23:03 PDT --- Also reproducible with '-inline -noboundscheck -O'. Should be a backend issue in gother.c. -------- struct H { double a; int[3] b; // must not be the first member in a struct, and must be an array with 3 or more members } void g(out int[3] t) { // must take 'out' parameter t[0]=0; // can be any mutating expression } void h (H* x) { // or 'out H' or 'ref H' g(x.b); } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 02, 2011 [Issue 5790] "Error: variable result used before set" when -release -inline -O | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jordi Rovira i Bonet | http://d.puremagic.com/issues/show_bug.cgi?id=5790 kennytm@gmail.com changed: What |Removed |Added ---------------------------------------------------------------------------- Platform|x86 |All --- Comment #5 from kennytm@gmail.com 2011-08-02 12:50:03 PDT --- Another test case, which is triggered only on Linux and FreeBSD. ----------------------------------- void test5790d() { int x; int y = *(1 + &x); } ----------------------------------- $ dmd -O -c test5790d.d Error: variable x used before set ----------------------------------- See also https://github.com/D-Programming-Language/dmd/pull/243#issuecomment-1706278. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 03, 2011 [Issue 5790] "Error: variable result used before set" when -release -inline -O | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jordi Rovira i Bonet | http://d.puremagic.com/issues/show_bug.cgi?id=5790 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@digitalmars.com --- Comment #6 from Walter Bright <bugzilla@digitalmars.com> 2011-08-03 09:58:41 PDT --- This is possibly related to: http://d.puremagic.com/issues/show_bug.cgi?id=5239 -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 04, 2011 [Issue 5790] "Error: variable result used before set" when -release -inline -O | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jordi Rovira i Bonet | http://d.puremagic.com/issues/show_bug.cgi?id=5790 Brad Roberts <braddr@puremagic.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |braddr@puremagic.com AssignedTo|nobody@puremagic.com |bugzilla@digitalmars.com --- Comment #7 from Brad Roberts <braddr@puremagic.com> 2011-08-03 20:41:58 PDT --- Confirmed that the reduction in comment 2 still reproduces the problem. It reports y2 as used before set (with no line number). The two fixes to this part of the compiler aren't sufficient to catch this one. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 11, 2012 [Issue 5790] "Error: variable result used before set" when -release -inline -O | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jordi Rovira i Bonet | http://d.puremagic.com/issues/show_bug.cgi?id=5790 Jonas Drewsen <jdrewsen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jdrewsen@gmail.com --- Comment #8 from Jonas Drewsen <jdrewsen@gmail.com> 2012-01-11 14:14:30 PST --- Additional test case using only the -O flag and no -inline or -release flags necessary. import std.typecons; void main(string[] args) { // Errors auto i = Tuple!(string,string)("foo", "bar")[1]; // Ok auto j = Tuple!(string,string)("foo", "bar"); auto k = j[1]; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
January 12, 2012 [Issue 5790] "Error: variable result used before set" when -release -inline -O | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jordi Rovira i Bonet | http://d.puremagic.com/issues/show_bug.cgi?id=5790 --- Comment #9 from Kenji Hara <k.hara.pg@gmail.com> 2012-01-12 01:12:06 PST --- (In reply to comment #8) > Additional test case using only the -O flag and no -inline or -release flags necessary. > > import std.typecons; > > void main(string[] args) { > > // Errors > auto i = Tuple!(string,string)("foo", "bar")[1]; > > // Ok > auto j = Tuple!(string,string)("foo", "bar"); > auto k = j[1]; > } This is a dup of 7263. See it. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation