This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15542] New: operator & and template definitions
- From: "heydowns at borg dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 May 2004 15:51:45 -0000
- Subject: [Bug c++/15542] New: operator & and template definitions
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Attached below is a simple C++ source file to demonstrate what appears to be a
name lookupor template generation bug in the new parser scheme. It has to do
with directly supplying the result of the application of the operator '&' to a
templated function, from within a template definition, when operator '&' is
overloaded in a templated class.
A call like this succeeds when the object whose & operator is invoked depends on
a templated parameter of the enclosing template definition. It fails when the
the object whose & operator is invoked is independent of the enclosing template
parameters. I am aware of the 3.4.0 changes regarding template definition
dependence and such, but I don't think any of that should apply here; it should
be able to find and generate the appropriate template instantiation.
The comments inline with the code explain further; the behavior seems very
inconsistent as exhibited by the examples. I believe the code to be valid. At
the very least I expect that the compiler would treat all provided scenarios
equally.
There is some preprocessor guarded code in the test code that, when included,
causes the entire thing to compile, seemingly by forceing the required template
instantiation.
Cmd Line for basic issue:
g++ -c file.cpp
Cmd Line to see external template generation causing compilation to succeed:
g++ -DTEST_TWO -c file.cpp
Errors produced during compilation using first cmd line, above:
file.cpp: In function `void templateTest(T&)':
file.cpp:56: error: no matching function for call to `templatedFunc(Opr<const
char>*&)'
file.cpp:57: error: cannot convert `Opr<const char>*' to `const char**' for
argument `1' to `void templatedFunc(T**) [with T = const char]'
This all worked in gcc 3.3.3.
gcc details:
Reading specs from /usr/local/lib/gcc/sparc-sun-solaris2.8/3.4.0/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as
--with-ld=/usr/ccs/bin/ld --disable-nls
Thread model: posix
gcc version 3.4.0
--
Summary: operator & and template definitions
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: heydowns at borg dot com
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15542