public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21972] New: Bad code generated
@ 2005-06-09 0:20 jordi dot prats at gmail dot com
2005-06-09 0:25 ` [Bug c++/21972] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: jordi dot prats at gmail dot com @ 2005-06-09 0:20 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/21972] Bad code generated
2005-06-09 0:20 [Bug c++/21972] New: Bad code generated jordi dot prats at gmail dot com
@ 2005-06-09 0:25 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-09 0:25 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-06-09 00:24 -------
Nope this is not generating bad code.
i<(p==NULL)?30:(p->bb+4)
is equivalent to
(i<(p==NULL))?30:(p->bb+4)
You want "i<((p==NULL)?30:(p->bb+4))".
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21972
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-06-09 0:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-09 0:20 [Bug c++/21972] New: Bad code generated jordi dot prats at gmail dot com
2005-06-09 0:25 ` [Bug c++/21972] " pinskia at gcc dot gnu dot 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).