This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: g++ does not honour "explicit" keyword in all cases?
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: 29 Oct 2003 18:47:15 +0100
- Subject: Re: g++ does not honour "explicit" keyword in all cases?
- Organization: Integrable Solutions
- References: <Pine.LNX.4.44.0310290942540.1646-100000@bellatrix.tat.physik.uni-tuebingen.de>
Richard Guenther <rguenth@tat.physik.uni-tuebingen.de> writes:
| Hi!
|
| Shouldnt g++ reject the following code, following 12.3.2?
|
| struct Foo {
| template <class T>
| explicit Foo(const T&) {}
| };
|
| template <class T>
| struct Bar {
| static T bar() { return 1; }
| };
|
| void foo(void)
| {
| Bar<double>::bar();
| }
|
| here Foo::Foo(const T&) is implicitly called from Bar::bar() returning
| int. Both gcc 3.3 and gcc 3.4 (and also intel icpc) accept these. But they
| should reject this for the same reason they reject
|
| void foo(void)
| {
| Foo i = 1.0;
| }
|
| ?
Hm, I guess there is something I'm missing here. From the definition
of Bar<double>::bar, the return type is double and there is no mention
of Foo, so I can't see what is wrong with the code.
-- Gaby