c++/10619: Instantiation through function template return type causes too cryptic error.

gccbugs@contacts.eelis.net gccbugs@contacts.eelis.net
Sun May 4 14:26:00 GMT 2003


>Number:         10619
>Category:       c++
>Synopsis:       Instantiation through function template return type causes too cryptic error.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun May 04 13:46:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Eelis van der Weegen
>Release:        gcc version 3.2.2 (mingw special 20030208-1)
>Organization:
>Environment:
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable-languages=c++,f77,objc --disable-win32-registry --disable-shared --enable-sjlj-exceptions
Thread model: win32
>Description:
When templates are instantiated through function template return types, errors during the instantiation are not always properly emitted. For example, given the following code:

  template <int I> struct A;
  template <int I> struct F { typename A<I>::type t; };
  template <int I> typename A<I>::type f ();

Instantiating F using:

  F<0> x;

causes a very clear error message:

  In instantiation of 'F<0>': instantiated from here [..] invalid use of undefined type 'struct A<0>'

However, performing the same instantiation through instantiating f() using:

  f<0>();

causes the following error:

  no matching function for call to 'f()'

This error seems to indicate an argument or CV-qualifier mismatch or something similar. It does not indicate that the problem occurs during the instantiation of the return type. Therefore, I think this error is too cryptic and, since cryptic errors lead to more time spent debugging, needs improvement. Something like:

  In instantiation of 'f<0>': instatiated from here [..] in instantiation of return type: invalid use of undefined 'struct A<0>'

would be ideal. What are your thoughts on this?
>How-To-Repeat:
Compile the code from the description.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-bugs mailing list