g++ compile fine (without any warning) this example program:

/*CODE*/

#include <iostream>

typedef struct sA
{
  int bb;
}AA;

int main()
{
  AA *p;
  
  p=NULL;

  for(int i=(p==NULL)?0:p->bb;i<(p==NULL)?30:(p->bb+4);i++)
    {
      std::cout << i;
    }

  return 1;
}

/*CODE*/

compile: g++ -g main.cxx -o main

If you try to execute it you'll get a segmentation fault. It should produce the
same output than with this for:

for(int i=0;i<30);i++)

-- 
           Summary: Bad code generated
           Product: gcc
           Version: 3.4.3
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jordi dot prats at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: GNU/Linux 2.6.11 AMD64
GCC target triplet: GNU/Linux 2.6.11 AMD64


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21972

Reply via email to