Compiling the following one line: void f(int i = 0, int j) {} produces the following error, as appropriate: [jjamison@manzanita]$ /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)' [jjamison@manzanita]$ 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) {} }; [jjamison@manzanita]$ /usr/misc/pkg/gcc-4.0.2/bin/g++ -c default.cc [jjamison@manzanita]$ This behavior is replicated in 4.0.1, 4.0.0, 3.4.4, and 3.4.3. [jjamison@manzanita]$ /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
This is a dup of bug 16829 which was fixed in 4.0.3. *** This bug has been marked as a duplicate of 16829 ***