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

* [Bug c++/13868] Conditional expression operator and implicit char array conversion
  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 ` pinskia at gcc dot gnu dot org
  2004-01-26 17:59 ` bangerth at dealii dot org
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-26 17:31 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-26 17:31 -------
Confirmed, not a regression though.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
           Keywords|                            |rejects-valid
      Known to fail|                            |2.97 3.0 3.0.1 3.0.2 3.0.3
                   |                            |3.0.4 3.1 3.1.1 3.1.2 3.2
                   |                            |3.2.1 3.2.2 3.2.3 3.3 3.3.1
                   |                            |3.3.2 3.3.3 3.4.0 3.5.0
   Last reconfirmed|0000-00-00 00:00:00         |2004-01-26 17:31:03
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13868


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c++/13868] Conditional expression operator and implicit char array conversion
  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
  1 sibling, 0 replies; 3+ messages in thread
From: bangerth at dealii dot org @ 2004-01-26 17:59 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From bangerth at dealii dot org  2004-01-26 17:59 -------
I'm not sure if 5.16/3 applies. The second argument to the ?: operator 
has type "const char[3]", and the third one can be converted to 
"char[4]". When I change this, then gcc accepts the code. 
 
On the other hand, 5.16/6 talks about array to pointer conversions. 
 
FWIW, icc accepts the code. 
 
W. 

-- 


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).