public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52231] New: [missed optimization/diagnostics] address-of-reference
@ 2012-02-13 13:33 pluto at agmk dot net
  2012-02-13 17:56 ` [Bug c++/52231] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: pluto at agmk dot net @ 2012-02-13 13:33 UTC (permalink / raw)
  To: gcc-bugs

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;
}


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-02-18 21:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-13 13:33 [Bug c++/52231] New: [missed optimization/diagnostics] address-of-reference pluto at agmk dot net
2012-02-13 17:56 ` [Bug c++/52231] " pinskia at gcc dot gnu.org
2012-02-13 18:13 ` redi at gcc dot gnu.org
2012-02-13 18:19 ` redi at gcc dot gnu.org
2015-02-18 19:36 ` pinskia at gcc dot gnu.org
2015-02-18 19:44 ` froydnj at gcc dot gnu.org
2015-02-18 21:30 ` redi at gcc dot gnu.org
2015-02-18 22:04 ` froydnj at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).