public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13868] New: Conditional expression operator and implicit char array conversion
@ 2004-01-26 17:20 joerg dot richter at pdv-fs dot de
2004-01-26 17:31 ` [Bug c++/13868] " pinskia at gcc dot gnu dot org
2004-01-26 17:59 ` bangerth at dealii dot org
0 siblings, 2 replies; 3+ messages in thread
From: joerg dot richter at pdv-fs dot de @ 2004-01-26 17:20 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-01-26 17:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-26 17:20 [Bug c++/13868] New: Conditional expression operator and implicit char array conversion joerg dot richter at pdv-fs dot de
2004-01-26 17:31 ` [Bug c++/13868] " pinskia at gcc dot gnu dot org
2004-01-26 17:59 ` bangerth at dealii 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).