This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/16718] wrong code-gen for (e1 ?: e2)()
- From: "bangerth at dealii dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Jul 2004 17:25:25 -0000
- Subject: [Bug c/16718] wrong code-gen for (e1 ?: e2)()
- References: <20040726164757.16718.djg@cs.washington.edu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bangerth at dealii dot org 2004-07-26 17:25 -------
Confirmed. To avoid trouble with a non-void function not returning
a value, the testcase should be written like this:
---------------
void h() {}
void g() { (h ?:0)(); }
int main() {g(); return 0;}
---------------
This program indeed crashes with gcc 3.2.x, 3.3.x and 3.4.x:
g/x> /home/bangerth/bin/gcc-3.2*/bin/gcc x.c ; ./a.out
Segmentation fault
g/x> /home/bangerth/bin/gcc-3.3*/bin/gcc x.c ; ./a.out
Segmentation fault
g/x> /home/bangerth/bin/gcc-3.4*/bin/gcc x.c ; ./a.out
Segmentation fault
It doesn't, however, with present mainline, and in addition prints a
very valid warning message:
g/x> /home/bangerth/bin/gcc-3.5*/bin/gcc x.c ; ./a.out
x.c: In function `g':
x.c:2: warning: the address of `h', will always evaluate as `true'
In other words: this is fixed already.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Known to fail| |3.5.0
Known to work| |3.2.3 3.3.3 3.4.0
Resolution| |FIXED
Target Milestone|--- |3.5.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16718