public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/42356] New: confused compiler
@ 2009-12-12 7:39 igodard at pacbell dot net
2009-12-12 9:48 ` [Bug c++/42356] " paolo dot carlini at oracle dot com
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: igodard at pacbell dot net @ 2009-12-12 7:39 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1647 bytes --]
This code:
template<typename T>
class freeList {
public:
T* newNode() { return 0; }
template<typename U>
T* newNode(U u) { return newNode()->init(u); }
template<typename U, typename V>
T* newNode(U u, V v) { return newNode()->init(u, v); }
};
class bar {};
class baz {};
class foo : public freeList<bar>, public freeList<baz> { };
int main() {
foo f;
bar* b = f.newNode<bar>();
}
gets you:
s3:~/ootbc/memspec$ g++ foo.cc
foo.cc: In function int main():
foo.cc:17: error: request for member newNode is ambiguous
foo.cc:8: error: candidates are: template<class U, class V> T*
freeList::newNode(U, V) [with U = U, V = V, T = baz]
foo.cc:6: error: candidates are: template<class U> T* freeList::newNode(U)
[with U = U, T = baz]
foo.cc:4: error: candidates are: T* freeList<T>::newNode() [with T = baz]
foo.cc:8: error: template<class U, class V> T*
freeList::newNode(U, V) [with U = U, V = V, T = bar]
foo.cc:6: error: template<class U> T* freeList::newNode(U)
[with U = U, T = bar]
foo.cc:4: error: T* freeList<T>::newNode() [with T = bar]
foo.cc:17: error: expected primary-expression before > token
foo.cc:17: error: expected primary-expression before ) token
--
Summary: confused compiler
Product: gcc
Version: 4.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: igodard at pacbell dot net
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42356
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/42356] confused compiler
2009-12-12 7:39 [Bug c++/42356] New: confused compiler igodard at pacbell dot net
@ 2009-12-12 9:48 ` paolo dot carlini at oracle dot com
2009-12-14 4:51 ` igodard at pacbell dot net
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-12-12 9:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from paolo dot carlini at oracle dot com 2009-12-12 09:47 -------
The basic error, at line 17, is definitely correct, and, for example, ICC
errors out exactly in the same way. I suppose you would like to see a nicer, in
some sense, list of candidates? (by the way, mailine is slightly better anyway,
because doesn't make the mistake of printing the words "candidates are:"
multiple times)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42356
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/42356] confused compiler
2009-12-12 7:39 [Bug c++/42356] New: confused compiler igodard at pacbell dot net
2009-12-12 9:48 ` [Bug c++/42356] " paolo dot carlini at oracle dot com
@ 2009-12-14 4:51 ` igodard at pacbell dot net
2009-12-14 8:45 ` paolo dot carlini at oracle dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: igodard at pacbell dot net @ 2009-12-14 4:51 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]
------- Comment #2 from igodard at pacbell dot net 2009-12-14 04:51 -------
Well, I see several issues with the diagnostics.
1) The call is not ambiguous, because if it were (only) ambiguous then removing
the base "baz" would disambiguate. Instead the case without "baz" gets you:
s3:~/ootbc/memspec$ g++ foo.cc
foo.cc: In function int main():
foo.cc:27: error: no matching function for call to foo::newNode()
That is, a call cannot be both ambiguous and have no matching function.
2) The reported list of overloads include those which have the wrong number of
arguments.
3) The diagnostic contains "freeList::newNode(U, V) [with U = U, V = V, T =
bar]" as the call citation, which makes it look like the local U matches a
(non-existent in this case) global U and local V matches a global V, the way
that local T matches global bar. Perhaps it could say something like
"freeList::newNode(U, V) [with U = ?, V = ?, T = bar]"
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42356
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/42356] confused compiler
2009-12-12 7:39 [Bug c++/42356] New: confused compiler igodard at pacbell dot net
2009-12-12 9:48 ` [Bug c++/42356] " paolo dot carlini at oracle dot com
2009-12-14 4:51 ` igodard at pacbell dot net
@ 2009-12-14 8:45 ` paolo dot carlini at oracle dot com
2009-12-14 9:27 ` paolo dot carlini at oracle dot com
2009-12-14 14:58 ` igodard at pacbell dot net
4 siblings, 0 replies; 8+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-12-14 8:45 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from paolo dot carlini at oracle dot com 2009-12-14 08:44 -------
I do not have the time to get into the language details, but I think you should
investigate the conformance of the code a bit more: recent SunStudio and Comeau
also agree with ICC and GCC on this.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42356
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/42356] confused compiler
2009-12-12 7:39 [Bug c++/42356] New: confused compiler igodard at pacbell dot net
` (2 preceding siblings ...)
2009-12-14 8:45 ` paolo dot carlini at oracle dot com
@ 2009-12-14 9:27 ` paolo dot carlini at oracle dot com
2009-12-14 14:58 ` igodard at pacbell dot net
4 siblings, 0 replies; 8+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-12-14 9:27 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from paolo dot carlini at oracle dot com 2009-12-14 09:27 -------
Likewise VC++ v8
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42356
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/42356] confused compiler
2009-12-12 7:39 [Bug c++/42356] New: confused compiler igodard at pacbell dot net
` (3 preceding siblings ...)
2009-12-14 9:27 ` paolo dot carlini at oracle dot com
@ 2009-12-14 14:58 ` igodard at pacbell dot net
4 siblings, 0 replies; 8+ messages in thread
From: igodard at pacbell dot net @ 2009-12-14 14:58 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from igodard at pacbell dot net 2009-12-14 14:58 -------
There's no question that there was an error here. The report is on the
diagnostic. I'm sorry if I hadn't made that clear.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42356
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/42356] confused compiler
[not found] <bug-42356-4@http.gcc.gnu.org/bugzilla/>
2011-09-28 21:28 ` paolo.carlini at oracle dot com
@ 2011-10-22 12:27 ` manu at gcc dot gnu.org
1 sibling, 0 replies; 8+ messages in thread
From: manu at gcc dot gnu.org @ 2011-10-22 12:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42356
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2011-10-22
CC| |manu at gcc dot gnu.org
Ever Confirmed|0 |1
--- Comment #7 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-10-22 12:27:11 UTC ---
Clang prints:
/tmp/webcompile/_26276_0.cc:17:19: error: no matching member function for call
to 'newNode'
bar* b = f.newNode<bar>();
~~^~~~~~~~~~~~
/tmp/webcompile/_26276_0.cc:6:13: note: candidate function template not viable:
requires 1 argument, but 0 were provided
T* newNode(U u) { return newNode()->init(u); }
^
/tmp/webcompile/_26276_0.cc:6:13: note: candidate function template not viable:
requires 1 argument, but 0 were provided
/tmp/webcompile/_26276_0.cc:8:13: note: candidate function template not viable:
requires 2 arguments, but 0 were provided
T* newNode(U u, V v) { return newNode()->init(u, v); }
^
/tmp/webcompile/_26276_0.cc:8:13: note: candidate function template not viable:
requires 2 arguments, but 0 were provided
which is nicer except for the duplicated messages.
The first thing that should go away is the "expected primary-expression" stuff.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug c++/42356] confused compiler
[not found] <bug-42356-4@http.gcc.gnu.org/bugzilla/>
@ 2011-09-28 21:28 ` paolo.carlini at oracle dot com
2011-10-22 12:27 ` manu at gcc dot gnu.org
1 sibling, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2011-09-28 21:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42356
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC|gcc-bugs at gcc dot gnu.org |
--- Comment #6 from Paolo Carlini <paolo.carlini at oracle dot com> 2011-09-28 21:21:40 UTC ---
For the record, ICC also thinks it's ambiguous.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-10-22 12:27 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-12 7:39 [Bug c++/42356] New: confused compiler igodard at pacbell dot net
2009-12-12 9:48 ` [Bug c++/42356] " paolo dot carlini at oracle dot com
2009-12-14 4:51 ` igodard at pacbell dot net
2009-12-14 8:45 ` paolo dot carlini at oracle dot com
2009-12-14 9:27 ` paolo dot carlini at oracle dot com
2009-12-14 14:58 ` igodard at pacbell dot net
[not found] <bug-42356-4@http.gcc.gnu.org/bugzilla/>
2011-09-28 21:28 ` paolo.carlini at oracle dot com
2011-10-22 12:27 ` manu at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).