This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/13868] New: Conditional expression operator and implicit char array conversion
- From: "joerg dot richter at pdv-fs dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 26 Jan 2004 17:20:35 -0000
- Subject: [Bug c++/13868] New: Conditional expression operator and implicit char array conversion
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Compile this program with GCC3.3.2:
----
struct Foo
{
typedef char type[4];
type mem;
operator type&()
{
return mem;
}
};
int main()
{
true ? "ab" : Foo();
return 0;
}
----
and you get the following output:
a.cc:14: no match for `bool ? const char[5] : Foo' operator
a.cc:14: candidates are: operator?:(bool, char*, char*) <built-in>
a.cc:14: operator?:(bool, const char*, const char*) <built-in>
I think this should compile. Using the user defined conversion to char (&) [4]
and then the array to pointer conversion on both sides. Then the qualification
conversion and you have the same types char const*.
Removing the need for the array to pointer conversion, by changing "ab"
to "abc" helps. Or removing the qualification conversion by changing the
implicit conversion to "operator type const&()" helps also.
--
Summary: Conditional expression operator and implicit char array
conversion
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: joerg dot richter at pdv-fs dot de
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13868