The following program compiles without error:

#include <iostream>
#include <string>
std::string f() {} main(){ std::string s(f()); return EXIT_SUCCESS; }

The function f() does not return a value, string s is filled with random areas
of memory.  The program segfaults.  gcc -v output from my machine (I tested
this on a few others):

[EMAIL PROTECTED] ~/temp $ gcc -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure  : (reconfigured) ../configure
--with-gcc-version-trigger=/root/gcc/gcc-4.0.0/gcc/version.c
--enable-languages=c,c++,java,objc --no-create --no-recursion
Thread model: posix
gcc version 4.0.0


-- 
           Summary: Compiler allows function not returning value to be used
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: aftli at optonline dot net


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

Reply via email to