g++ 4.0.1 gives incorrect error message with void function declaration &  
implementation when using void main(). This can be demonstrated with the  
following program:  
  
------  
void f1();  
  
void main()  
{     
   f1();  
}  
  
void f1()  
{     
}  
----  
  
The resulting error message is:  
gccbug.cc:3: error: '::main' must return 'int'  
gccbug.cc: In function 'void f1()':  
gccbug.cc:8: error: new declaration 'void f1()'  
gccbug.cc:1: error: ambiguates old declaration 'int f1()'  
  
Granted, using void for return value of main() is an error, but so is the  
resulting message.   
The error message is correct with gcc 3.3.5 and 3.4.4 (debian prerelease). 
 
  
Since "Reporting bugs" web page requested the environment,  
gcc -v gives:  
Using built-in specs.  
Target: i486-linux-gnu  
Configured with: ../src/configure -v  
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr  
--enable-shared --with-system-zlib --libexecdir=/usr/lib --enable-nls  
--without-included-gettext --enable-threads=posix --program-suffix=-4.0  
--enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu  
--enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk  
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr  
--disable-werror --enable-checking=release i486-linux-gnu  
Thread model: posix  
gcc version 4.0.1 (Debian 4.0.1-2)  
  
system:  
Linux maestro 2.6.12.1 #1 SMP Sun Jun 26 16:24:58 EEST 2005 i686 GNU/Linux

-- 
           Summary: g++ gives incorrect error message with void main() and a
                    void function
           Product: gcc
           Version: 4.0.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: pvuorela at iki dot fi
                CC: gcc-bugs at gcc dot gnu dot org
GCC target triplet: i486-linux-gnu


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

Reply via email to