public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/62110] New: Attempting to use template conversion operator in a contextual conversion
@ 2014-08-12 19:27 yaghmour.shafik at gmail dot com
2014-08-12 20:31 ` [Bug c++/62110] " redi at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: yaghmour.shafik at gmail dot com @ 2014-08-12 19:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62110
Bug ID: 62110
Summary: Attempting to use template conversion operator in a
contextual conversion
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: yaghmour.shafik at gmail dot com
Given the following code:
class Var
{
public:
operator int () const
{ return 0; }
template <typename T>
operator T () const
{ return T(); }
};
int main()
{
Var v;
switch (v)
{ }
}
gcc 4.9 produces the following error:
main.cpp: In function 'int main()':
main.cpp:17:14: error: default type conversion can't deduce template argument
for 'template<class T> Var::operator T() const'
switch (v)
^
using the following command line options:
-std=c++11 -Wall -Wextra -Wconversion -pedantic
Using -std=c++1y also produces the same error.
while clang 3.4 does not produce any errors. As far as I can tell clang is
correct here for C++1y and is probably correct for C++11 although that may
depend on whether you consider N3323: "A Proposal to Tweak Certain C++
Contextual Conversions" to be a fix for C++11 or part of C++1y.
N3323 is incorporated in N3485 which I consider to be C++11 with fixes but
perhaps that is an incorrect interpretation. Based on this assumption then if
we look at section 6.4.2 it says:
The condition shall be of integral type, enumeration type, or class type. If of
class type, the condition is contextually implicitly converted (Clause 4) to an
integral or enumeration type.
and this would force us to use section 4 paragraph 5 which does not allow or
overload resolution making int conversion the only one available for this
context.
If N3323 is not part of C++11 then it seems unclear to me whether the template
conversion function should be considered or not.
This bug report comes the following Stackoverflow question:
http://stackoverflow.com/questions/25047109/classes-with-both-template-and-non-template-conversion-operators-in-the-conditio
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/62110] Attempting to use template conversion operator in a contextual conversion
2014-08-12 19:27 [Bug c++/62110] New: Attempting to use template conversion operator in a contextual conversion yaghmour.shafik at gmail dot com
@ 2014-08-12 20:31 ` redi at gcc dot gnu.org
2014-08-12 23:27 ` rs2740 at gmail dot com
2014-12-14 0:28 ` ville.voutilainen at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2014-08-12 20:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62110
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
N3323 is not addressing a DR, so is not part of C++11.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/62110] Attempting to use template conversion operator in a contextual conversion
2014-08-12 19:27 [Bug c++/62110] New: Attempting to use template conversion operator in a contextual conversion yaghmour.shafik at gmail dot com
2014-08-12 20:31 ` [Bug c++/62110] " redi at gcc dot gnu.org
@ 2014-08-12 23:27 ` rs2740 at gmail dot com
2014-12-14 0:28 ` ville.voutilainen at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: rs2740 at gmail dot com @ 2014-08-12 23:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62110
TC <rs2740 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |rs2740 at gmail dot com
--- Comment #2 from TC <rs2740 at gmail dot com> ---
According to https://gcc.gnu.org/projects/cxx1y.html, N3323 should have been
implemented in GCC 4.9 with -std=c++1y.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/62110] Attempting to use template conversion operator in a contextual conversion
2014-08-12 19:27 [Bug c++/62110] New: Attempting to use template conversion operator in a contextual conversion yaghmour.shafik at gmail dot com
2014-08-12 20:31 ` [Bug c++/62110] " redi at gcc dot gnu.org
2014-08-12 23:27 ` rs2740 at gmail dot com
@ 2014-12-14 0:28 ` ville.voutilainen at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-12-14 0:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62110
Ville Voutilainen <ville.voutilainen at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |rejects-valid
Status|UNCONFIRMED |NEW
Last reconfirmed| |2014-12-14
CC| |ville.voutilainen at gmail dot com
Ever confirmed|0 |1
Known to fail| |4.8.2, 4.9.1, 5.0
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-12-14 0:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-12 19:27 [Bug c++/62110] New: Attempting to use template conversion operator in a contextual conversion yaghmour.shafik at gmail dot com
2014-08-12 20:31 ` [Bug c++/62110] " redi at gcc dot gnu.org
2014-08-12 23:27 ` rs2740 at gmail dot com
2014-12-14 0:28 ` ville.voutilainen at gmail dot com
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).