This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21972] New: Bad code generated
- From: "jordi dot prats at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Jun 2005 00:20:08 -0000
- Subject: [Bug c++/21972] New: Bad code generated
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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