public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/23227] New: SFINAE bug
@ 2005-08-04 9:30 sylvain dot pion at sophia dot inria dot fr
2005-08-04 13:07 ` [Bug c++/23227] " pinskia at gcc dot gnu dot org
` (8 more replies)
0 siblings, 9 replies; 15+ messages in thread
From: sylvain dot pion at sophia dot inria dot fr @ 2005-08-04 9:30 UTC (permalink / raw)
To: gcc-bugs
The following code refuses to compile :
----------------------------
struct C;
template < typename T >
struct B;
template < typename T >
struct A;
void f(const C &c); // this one is fine
void f(const B<C> &a); // this one is fine
void f(const A<C> &a); // this one triggers the bug
void f(double) {}
template < typename T >
struct A
{
B<T> b;
};
int main()
{
f(1.0); // => instantiates A<C> => instantiates B<C> => fails.
}
-------------------------------
The error message is :
instance.C: In instantiation of 'A<C>':
instance.C:23: instantiated from here
instance.C:17: error: 'A<T>::b' has incomplete type
instance.C:4: error: declaration of 'struct B<C>'
I am not 100% sure it is a SFINAE bug, but it looks like one to me.
Note that if you comment the declaration of f(A<C>), then it works.
Similarly if you comment the definition of A.
So the problem here is probably that if the definition of A is
available, then the compiler instantiates it, which triggers the
instantiation of B<T>, which fails, but the compiler does not
recover from this instantiation as it should (following SFINAE).
There is the same problem with g++ 3.3, 3.4 and 4.0.1.
--
Summary: SFINAE bug
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sylvain dot pion at sophia dot inria dot fr
CC: gcc-bugs at gcc dot gnu dot org,sylvain dot pion at
sophia dot inria dot fr
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/23227] SFINAE bug
2005-08-04 9:30 [Bug c++/23227] New: SFINAE bug sylvain dot pion at sophia dot inria dot fr
@ 2005-08-04 13:07 ` pinskia at gcc dot gnu dot org
2005-08-04 13:27 ` gdr at integrable-solutions dot net
` (7 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-04 13:07 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-04 13:07 -------
IIRC SFINAE does not mean not instantiating the template class.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/23227] SFINAE bug
2005-08-04 9:30 [Bug c++/23227] New: SFINAE bug sylvain dot pion at sophia dot inria dot fr
2005-08-04 13:07 ` [Bug c++/23227] " pinskia at gcc dot gnu dot org
@ 2005-08-04 13:27 ` gdr at integrable-solutions dot net
2005-08-05 4:02 ` pinskia at gcc dot gnu dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-08-04 13:27 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at integrable-solutions dot net 2005-08-04 13:26 -------
Subject: Re: SFINAE bug
"pinskia at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| IIRC SFINAE does not mean not instantiating the template class.
That is true. However, the real issue has nothing to do with SFINAE.
The compiler is just plain buggy.
Sylvain -- don't describe a plain compiler bug as SFINAE, otherwise
people might be sidetracked :-)
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/23227] SFINAE bug
2005-08-04 9:30 [Bug c++/23227] New: SFINAE bug sylvain dot pion at sophia dot inria dot fr
2005-08-04 13:07 ` [Bug c++/23227] " pinskia at gcc dot gnu dot org
2005-08-04 13:27 ` gdr at integrable-solutions dot net
@ 2005-08-05 4:02 ` pinskia at gcc dot gnu dot org
2005-09-14 15:35 ` bangerth at dealii dot org
` (5 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-08-05 4:02 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-08-05 04:02 -------
I don't think this is a bug as A<C> will be tried to be instantiating while trying to convert it from float.
ICC gives the same result as GCC, an error.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/23227] SFINAE bug
2005-08-04 9:30 [Bug c++/23227] New: SFINAE bug sylvain dot pion at sophia dot inria dot fr
` (2 preceding siblings ...)
2005-08-05 4:02 ` pinskia at gcc dot gnu dot org
@ 2005-09-14 15:35 ` bangerth at dealii dot org
2005-09-14 21:03 ` gdr at integrable-solutions dot net
` (4 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: bangerth at dealii dot org @ 2005-09-14 15:35 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-09-14 15:35 -------
I believe the compiler is correct. In order to check whether there
is a conversion sequence from float to A<C>, it needs to instantiate the
type, parts of which are declared by incomplete. This should be an error.
icc says the same, whatever this means.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/23227] SFINAE bug
2005-08-04 9:30 [Bug c++/23227] New: SFINAE bug sylvain dot pion at sophia dot inria dot fr
` (3 preceding siblings ...)
2005-09-14 15:35 ` bangerth at dealii dot org
@ 2005-09-14 21:03 ` gdr at integrable-solutions dot net
2005-09-14 21:11 ` bangerth at dealii dot org
` (3 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-09-14 21:03 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at integrable-solutions dot net 2005-09-14 21:03 -------
Subject: Re: SFINAE bug
"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| I believe the compiler is correct. In order to check whether there
| is a conversion sequence from float to A<C>, it needs to instantiate the
| type, parts of which are declared by incomplete. This should be an error.
I don't think I agree.
Consider
stuct A;
void f(const A&) { }
void f(int) { }
void g()
{
f(2.0);
}
We don't reject the call in g() just because A happens to be incomplete
-- therefore we could not "look into" it for determining whether it
needs an implicit conversion or not. In another words, It is not
clear whether the completeness of A<C> is required in the testcase
submitted.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/23227] SFINAE bug
2005-08-04 9:30 [Bug c++/23227] New: SFINAE bug sylvain dot pion at sophia dot inria dot fr
` (4 preceding siblings ...)
2005-09-14 21:03 ` gdr at integrable-solutions dot net
@ 2005-09-14 21:11 ` bangerth at dealii dot org
2005-09-14 21:23 ` pinskia at gcc dot gnu dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 15+ messages in thread
From: bangerth at dealii dot org @ 2005-09-14 21:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From bangerth at dealii dot org 2005-09-14 21:10 -------
Fair enough. And to get more to the point of only using user-defined
conversion sequences (instead of the standard conversion from double
to int):
--------------------
struct A;
struct B { B(const double &); };
void f(const A&) { }
void f(const B&) { }
void g()
{
f(2.0);
}
----------------------
This is accepted by all compilers I have as well.
I retract my point of view. This doesn't mean, however, that I'm convinced
that the opposite would be true.
W.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/23227] SFINAE bug
2005-08-04 9:30 [Bug c++/23227] New: SFINAE bug sylvain dot pion at sophia dot inria dot fr
` (5 preceding siblings ...)
2005-09-14 21:11 ` bangerth at dealii dot org
@ 2005-09-14 21:23 ` pinskia at gcc dot gnu dot org
2005-09-14 22:11 ` gdr at integrable-solutions dot net
2005-09-18 19:43 ` fang at csl dot cornell dot edu
8 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-09-14 21:23 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-09-14 21:23 -------
(In reply to comment #6)
> I retract my point of view. This doesn't mean, however, that I'm convinced
> that the opposite would be true.
But both of those testcases represent "void f(const B<C> &a); ".
Here is how I see it:
A<T> is instantiated because it is defined as a way too instantiate it and then we reject it as having
referencing an incomplete type.
The question here is should we be instantiating A<C>? I saw yes because otherwise we would reject
other valid code where A<C> defines a constructor taking double.
And the other question is if we instantiate A<C> should we be erroring out, I say yes as there is no part
of the standard as far as I can see says we should not error out here.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/23227] SFINAE bug
2005-08-04 9:30 [Bug c++/23227] New: SFINAE bug sylvain dot pion at sophia dot inria dot fr
` (6 preceding siblings ...)
2005-09-14 21:23 ` pinskia at gcc dot gnu dot org
@ 2005-09-14 22:11 ` gdr at integrable-solutions dot net
2005-09-18 19:43 ` fang at csl dot cornell dot edu
8 siblings, 0 replies; 15+ messages in thread
From: gdr at integrable-solutions dot net @ 2005-09-14 22:11 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From gdr at integrable-solutions dot net 2005-09-14 22:11 -------
Subject: Re: SFINAE bug
"bangerth at dealii dot org" <gcc-bugzilla@gcc.gnu.org> writes:
| Fair enough. And to get more to the point of only using user-defined
| conversion sequences (instead of the standard conversion from double
| to int):
| --------------------
| struct A;
| struct B { B(const double &); };
|
| void f(const A&) { }
| void f(const B&) { }
|
| void g()
| {
| f(2.0);
| }
| ----------------------
| This is accepted by all compilers I have as well.
|
| I retract my point of view. This doesn't mean, however, that I'm convinced
| that the opposite would be true.
In fact, I've come to be on the same position: I don't know. This is
probably something we need to forward to CWG.
-- Gaby
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/23227] SFINAE bug
2005-08-04 9:30 [Bug c++/23227] New: SFINAE bug sylvain dot pion at sophia dot inria dot fr
` (7 preceding siblings ...)
2005-09-14 22:11 ` gdr at integrable-solutions dot net
@ 2005-09-18 19:43 ` fang at csl dot cornell dot edu
8 siblings, 0 replies; 15+ messages in thread
From: fang at csl dot cornell dot edu @ 2005-09-18 19:43 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |fang at csl dot cornell dot
| |edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/23227] SFINAE bug
[not found] <bug-23227-1902@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2009-03-04 1:28 ` jason at gcc dot gnu dot org
@ 2009-03-04 1:29 ` jason at gcc dot gnu dot org
2009-03-04 1:29 ` jason at gcc dot gnu dot org
4 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-03-04 1:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #13 from jason at gcc dot gnu dot org 2009-03-04 01:29 -------
Invalid.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/23227] SFINAE bug
[not found] <bug-23227-1902@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2009-03-04 1:29 ` jason at gcc dot gnu dot org
@ 2009-03-04 1:29 ` jason at gcc dot gnu dot org
4 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-03-04 1:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #12 from jason at gcc dot gnu dot org 2009-03-04 01:28 -------
oops, wrong resolution.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|FIXED |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/23227] SFINAE bug
[not found] <bug-23227-1902@http.gcc.gnu.org/bugzilla/>
2009-02-22 16:29 ` steven at gcc dot gnu dot org
2009-02-22 16:39 ` paolo dot carlini at oracle dot com
@ 2009-03-04 1:28 ` jason at gcc dot gnu dot org
2009-03-04 1:29 ` jason at gcc dot gnu dot org
2009-03-04 1:29 ` jason at gcc dot gnu dot org
4 siblings, 0 replies; 15+ messages in thread
From: jason at gcc dot gnu dot org @ 2009-03-04 1:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from jason at gcc dot gnu dot org 2009-03-04 01:28 -------
This can't be a SFINAE issue, as the f's in question aren't templates. The
compiler instantiates A<C> in order to determine whether or not there's a
conversion from double to A<C>, and that instantiation fails. This isn't a
bug.
--
jason at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/23227] SFINAE bug
[not found] <bug-23227-1902@http.gcc.gnu.org/bugzilla/>
2009-02-22 16:29 ` steven at gcc dot gnu dot org
@ 2009-02-22 16:39 ` paolo dot carlini at oracle dot com
2009-03-04 1:28 ` jason at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 15+ messages in thread
From: paolo dot carlini at oracle dot com @ 2009-02-22 16:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from paolo dot carlini at oracle dot com 2009-02-22 16:38 -------
CC-ing Jason seems a good idea...
--
paolo dot carlini at oracle dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug c++/23227] SFINAE bug
[not found] <bug-23227-1902@http.gcc.gnu.org/bugzilla/>
@ 2009-02-22 16:29 ` steven at gcc dot gnu dot org
2009-02-22 16:39 ` paolo dot carlini at oracle dot com
` (3 subsequent siblings)
4 siblings, 0 replies; 15+ messages in thread
From: steven at gcc dot gnu dot org @ 2009-02-22 16:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from steven at gcc dot gnu dot org 2009-02-22 16:29 -------
>3 years of inaction. What is going to be done about this?
--
steven at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23227
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2009-03-04 1:29 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-04 9:30 [Bug c++/23227] New: SFINAE bug sylvain dot pion at sophia dot inria dot fr
2005-08-04 13:07 ` [Bug c++/23227] " pinskia at gcc dot gnu dot org
2005-08-04 13:27 ` gdr at integrable-solutions dot net
2005-08-05 4:02 ` pinskia at gcc dot gnu dot org
2005-09-14 15:35 ` bangerth at dealii dot org
2005-09-14 21:03 ` gdr at integrable-solutions dot net
2005-09-14 21:11 ` bangerth at dealii dot org
2005-09-14 21:23 ` pinskia at gcc dot gnu dot org
2005-09-14 22:11 ` gdr at integrable-solutions dot net
2005-09-18 19:43 ` fang at csl dot cornell dot edu
[not found] <bug-23227-1902@http.gcc.gnu.org/bugzilla/>
2009-02-22 16:29 ` steven at gcc dot gnu dot org
2009-02-22 16:39 ` paolo dot carlini at oracle dot com
2009-03-04 1:28 ` jason at gcc dot gnu dot org
2009-03-04 1:29 ` jason at gcc dot gnu dot org
2009-03-04 1:29 ` jason at gcc dot gnu dot 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).