From mboxrd@z Thu Jan 1 00:00:00 1970 From: wolfgang.bangerth@iwr.uni-heidelberg.de To: gcc-gnats@gcc.gnu.org Subject: c++/2864: misleading error message about default arg initialization Date: Fri, 18 May 2001 02:06:00 -0000 Message-id: <20010518090035.29836.qmail@sourceware.cygnus.com> X-SW-Source: 2001-05/msg00440.html List-Id: >Number: 2864 >Category: c++ >Synopsis: misleading error message about default arg initialization >Confidential: no >Severity: non-critical >Priority: low >Responsible: unassigned >State: open >Class: change-request >Submitter-Id: net >Arrival-Date: Fri May 18 02:06:01 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Wolfgang Bangerth >Release: unknown-1.0 >Organization: >Environment: gcc 2.95, gcc cvs of May 05 >Description: Initializing a default arg by the value of another argument to the same function is not allowed and detected at the spot of the attempt by gcc for non-template classes. However, for template classes, the error message pops up at the point of instantiation which confuses the user as the name of the object to which the compiler objects is not used in that scope. It would be more appropriate to either detect the error when parsing the template class, or at least attribute the error to the place of the erroneous declaration. Regards Wolfgang Wolfgang >How-To-Repeat: -----/gcc-bugs> cat a.cc template struct X { X (int i=0, int j=i); }; X<1> x; -----/gcc-bugs> ~/Config/gcc-ss-sun/bin/gcc -W -Wall -ansi -c a.cc -o /dev/null a.cc: In function `void __static_initialization_and_destruction_0(int, int)': a.cc:6: `i' undeclared (first use this function) a.cc:6: (Each undeclared identifier is reported only once a.cc:6: for each function it appears in.) -----/gcc-bugs> ~/Config/gcc-ss-sun/bin/gcc -v Reading specs from /home/atlas2/wolf/Config/gcc-ss-sun/bin/../lib/gcc-lib/sparc-sun-solaris2.7/3.0/specs Configured with: ../gcc/configure --prefix=/home/people/wolf/Config/gcc-ss-sun --with-gnu-as --with-as=/usr/local/bin/as --with-gnu-ld --with-ld=/usr/local/bin/ld Thread model: posix gcc version 3.0 20010514 (prerelease) >Fix: >Release-Note: >Audit-Trail: >Unformatted: