This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/16718] wrong code-gen for (e1 ?: e2)()


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]