[Bug c++/52231] New: [missed optimization/diagnostics] address-of-reference
pluto at agmk dot net
gcc-bugzilla@gcc.gnu.org
Mon Feb 13 13:33:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52231
Bug #: 52231
Summary: [missed optimization/diagnostics] address-of-reference
Classification: Unclassified
Product: gcc
Version: 4.6.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: pluto@agmk.net
int& singleton();
void foo();
void bar()
{
int& a = singleton();
int& b = singleton();
if ( &a == 0 ) <== useless stmt (not diagnosed/not optimized)
foo();
a = 5;
if ( b != 5 )
foo();
}
in c++ the adress of refer
$ g++ 0.cpp -O2 -Wall -Wextra -fdump-tree-optimized -c && cat
0.cpp.143t.optimized
void bar() ()
{
int & D.2079;
int & D.2078;
int D.2074;
<bb 2>:
D.2078_1 = singleton ();
D.2079_3 = singleton ();
if (D.2078_1 == 0B) <========
goto <bb 3>;
else
goto <bb 4>;
<bb 3>:
foo ();
<bb 4>:
*D.2078_1 = 5;
D.2074_5 = *D.2079_3;
if (D.2074_5 != 5)
goto <bb 5>;
else
goto <bb 6>;
<bb 5>:
foo (); [tail call]
<bb 6>:
return;
}
More information about the Gcc-bugs
mailing list