Compiling the following one line:

   void f(int i = 0, int j) {}

produces the following error, as appropriate:

[EMAIL PROTECTED] /usr/misc/pkg/gcc-4.0.2/bin/g++ -c default.cc
default.cc: In function `void f(int, int)':
default.cc:1: error: default argument missing for parameter 2 of `void f(int,
int)'
[EMAIL PROTECTED]

However, compiling the following analogous code produces no errors, even though
it should:

   struct T {
      T(int i = 0, int j) {}
      void m(int i = 0, int j) {}
   };

[EMAIL PROTECTED] /usr/misc/pkg/gcc-4.0.2/bin/g++ -c default.cc
[EMAIL PROTECTED]

This behavior is replicated in 4.0.1, 4.0.0, 3.4.4, and 3.4.3.

[EMAIL PROTECTED] /usr/misc/pkg/gcc-4.0.2/bin/g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc-4.0.2/configure --prefix=/usr/misc/pkg/gcc-4.0.2
--enable-shared --enable-threads=posix --with-system-zlib --with-gnu-as
--with-as=/usr/misc/pkg/binutils-2.16/bin/as --with-gnu-ld
--with-ld=/usr/misc/pkg/binutils-2.16/bin/ld --enable-__cxa_atexit
--enable-languages=c,c++
Thread model: posix
gcc version 4.0.2


-- 
           Summary: g++ allows params with default arguments to the left of
                    those without
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jjamison at cs dot berkeley dot edu
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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

Reply via email to