This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/2864: misleading error message about default arg initialization
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/2864: misleading error message about default arg initialization
- From: wolfgang dot bangerth at iwr dot uni-heidelberg dot de
- Date: 18 May 2001 09:00:35 -0000
- Reply-To: wolfgang dot bangerth at iwr dot uni-heidelberg dot de
>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 <int dim> 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: