public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/4337: [2003-01-01]c++ ignores cast operator
@ 2003-05-14  0:46 Giovanni Bajo
  0 siblings, 0 replies; 3+ messages in thread
From: Giovanni Bajo @ 2003-05-14  0:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/4337; it has been noted by GNATS.

From: "Giovanni Bajo" <giovannibajo@libero.it>
To: "Bogdanov, Serge" <serge.bogdanov@intel.com>,
	<gcc-bugs@gcc.gnu.org>,
	<gcc-prs@gcc.gnu.org>,
	<nobody@gcc.gnu.org>,
	<gcc-gnats@gcc.gnu.org>
Cc:  
Subject: Re: c++/4337: [2003-01-01]c++ ignores cast operator
Date: Wed, 14 May 2003 02:36:09 +0200

 Bogdanov, Serge <serge.bogdanov@intel.com> wrote:
 
 >       The latest analysis by Giovanni solves one mystery, but there is
 > another one in the same bug report: if the cast operator is removed,
 > compiler produces warnings.
 >
 >>>> g++ -o a a.cpp
 > a.cpp: In function `int main()':
 > a.cpp:27: warning: choosing `A2::operator A1()' over `A1::A1(const A&)'
 > a.cpp:27: warning:   for conversion from `A2' to `A1'
 > a.cpp:27: warning:   because conversion sequence for the argument is
 better
 
 And what would the problem be? If you remove the cast operator, you end up
 with "a2 = a1" which obviously selects the cast operator. The compiler is
 just warning you about the possible ambiguity, but it's choosing the right
 path.
 
 Giovanni Bajo
 


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

* RE: c++/4337: [2003-01-01]c++ ignores cast operator
@ 2003-05-13 21:19 Bogdanov, Serge
  0 siblings, 0 replies; 3+ messages in thread
From: Bogdanov, Serge @ 2003-05-13 21:19 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR c++/4337; it has been noted by GNATS.

From: "Bogdanov, Serge" <serge.bogdanov@intel.com>
To: "'giovannibajo@libero.it'" <giovannibajo@libero.it>,
   "'gcc-bugs@gcc.gnu.org'" <gcc-bugs@gcc.gnu.org>,
   "'gcc-prs@gcc.gnu.org'"
	 <gcc-prs@gcc.gnu.org>,
   "'nobody@gcc.gnu.org'" <nobody@gcc.gnu.org>,
   "Bogdanov, Serge" <serge.bogdanov@intel.com>,
   "'gcc-gnats@gcc.gnu.org'"
	 <gcc-gnats@gcc.gnu.org>
Cc:  
Subject: RE: c++/4337: [2003-01-01]c++ ignores cast operator
Date: Tue, 13 May 2003 14:11:50 -0700

 This message is in MIME format. Since your mail reader does not understand
 this format, some or all of this message may not be legible.
 
 ------_=_NextPart_001_01C31994.45348570
 Content-Type: text/plain;
 	charset="iso-8859-1"
 Content-Transfer-Encoding: quoted-printable
 
 Hi,
 
 =20
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=3Dview%20audittrail&database=3D=
 gcc&pr
 =3D4337
 
 =20
 
       The latest analysis by Giovanni solves one mystery, but there is
 another one in the same bug report: if the cast operator is removed,
 compiler produces warnings.
 
 =20
 
 >>> g++ -o a a.cpp
 
 a.cpp: In function `int main()':
 
 a.cpp:27: warning: choosing `A2::operator A1()' over `A1::A1(const A&)'
 
 a.cpp:27: warning:   for conversion from `A2' to `A1'
 
 a.cpp:27: warning:   because conversion sequence for the argument is =
 better
 
 =20
 
 btw, the attempt to use a cast operator was caused by these messages.
 Therefore I think that the issue is not closed yet. Please re-open =
 it.to use
 a cast operator was caused by these messages
 
 =20
 
 I tried it with gcc 3.2.2.
 
 =20
 
 >> Sergey Bogdanov
 
 intel corporation
 
 SHR1-1/S30
 
 334 South Street, Shrewsbury, MA 01745
 
 Tel: (508) 841-1618
 
 =20
 
 -----Original Message-----
 From: giovannibajo@libero.it [mailto:giovannibajo@libero.it]=20
 Sent: Sunday, May 04, 2003 9:14 PM
 To: gcc-bugs@gcc.gnu.org; gcc-prs@gcc.gnu.org; nobody@gcc.gnu.org;
 serge.bogdanov@intel.com
 Subject: Re: c++/4337: [2003-01-01]c++ ignores cast operator
 
 =20
 
 Synopsis: [2003-01-01]c++ ignores cast operator
 
 =20
 
 State-Changed-From-To: analyzed->closed
 
 State-Changed-By: bajo
 
 State-Changed-When: Mon May  5 01:14:02 2003
 
 State-Changed-Why:
 
     Not a bug. "a1 =3D (A1)a2" is a type conversion in cast=20
 
     notation (=A75.4). "a1 =3D const_cast<A1>(a2)" is=20
 
     ill-formed, but "a1 =3D static_cast<A1>(a2)" is well-formed,
 
     because "a1 =3D A1(a2)" is well-formed (this is the exact
 
     condition specified by =A75.2.9p2). Thus, for =A75.4p5, the
 
     cast notation is equivalent to the static_cast notation.
 
     The static_cast notation is then equivalent to=20
 
     "a1 =3D A1(a2)", which upcasts a2 to const A& implicitally,
 
     and then invokes A1(const A&).=20
 
     G++ behaves exactly as the standard prescribes, and all
 
     the other compilers I have agree.
 
     If you need to force the use of the custom conversion=20
 
     operator, you can still do it using the syntax
 
     "a1 =3D a2.operator A1()".
 
 =20
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=3Dview%20audittrail&database=3D=
 gcc&pr
 =3D4337
 
 
 ------_=_NextPart_001_01C31994.45348570
 Content-Type: text/html;
 	charset="iso-8859-1"
 Content-Transfer-Encoding: quoted-printable
 
 <html>
 
 <head>
 <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
 charset=3Diso-8859-1">
 
 
 <meta name=3DGenerator content=3D"Microsoft Word 10 (filtered)">
 
 <style>
 <!--
  /* Style Definitions */
  p.MsoNormal, li.MsoNormal, div.MsoNormal
 	{margin:0in;
 	margin-bottom:.0001pt;
 	font-size:12.0pt;
 	font-family:"Times New Roman";}
 a:link, span.MsoHyperlink
 	{color:blue;
 	text-decoration:underline;}
 a:visited, span.MsoHyperlinkFollowed
 	{color:purple;
 	text-decoration:underline;}
 p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
 	{margin:0in;
 	margin-bottom:.0001pt;
 	font-size:10.0pt;
 	font-family:"Courier New";}
 @page Section1
 	{size:8.5in 11.0in;
 	margin:1.0in 77.95pt 1.0in 77.95pt;}
 div.Section1
 	{page:Section1;}
 -->
 </style>
 
 </head>
 
 <body lang=3DEN-US link=3Dblue vlink=3Dpurple>
 
 <div class=3DSection1>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>Hi,</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>&nbsp;</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=3Dview%20audittrail&a=
 mp;database=3Dgcc&amp;pr=3D4337</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>&nbsp;</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0=A0=A0=A0 The latest analysis by Giovanni solves one =
 mystery, but there is
 another one in the same bug report: if the cast operator is removed, =
 compiler
 produces warnings.</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>&nbsp;</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>&gt;&gt;&gt; g++ -o a a.cpp</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>a.cpp: In function `int main()':</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>a.cpp:27: warning: choosing `A2::operator A1()' over =
 `A1::A1(const
 A&amp;)'</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>a.cpp:27: warning:=A0=A0 for conversion from `A2' to =
 `A1'</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>a.cpp:27: warning:=A0=A0 because conversion sequence for the =
 argument is
 better</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>&nbsp;</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>btw, the attempt to use a cast operator was caused by these =
 messages.
 Therefore I think that the issue is not closed yet. Please re-open =
 it.<span
 style=3D'display:none'>to use a cast operator was caused by these =
 messages</span></span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>&nbsp;</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>I tried it with gcc 3.2.2.</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>&nbsp;</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>&gt;&gt; Sergey Bogdanov</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>intel corporation</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>SHR1-1/S30</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>334 South Street, Shrewsbury, MA 01745</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>Tel: (508) 841-1618</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>&nbsp;</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>-----Original Message-----<br>
 From: giovannibajo@libero.it [mailto:giovannibajo@libero.it] <br>
 Sent: Sunday, May 04, 2003 9:14 PM<br>
 To: gcc-bugs@gcc.gnu.org; gcc-prs@gcc.gnu.org; nobody@gcc.gnu.org;
 serge.bogdanov@intel.com<br>
 Subject: Re: c++/4337: [2003-01-01]c++ ignores cast =
 operator</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>&nbsp;</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>Synopsis: [2003-01-01]c++ ignores cast =
 operator</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>&nbsp;</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>State-Changed-From-To: analyzed-&gt;closed</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>State-Changed-By: bajo</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>State-Changed-When: Mon May=A0 5 01:14:02 =
 2003</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>State-Changed-Why:</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0=A0 Not a bug. &quot;a1 =3D (A1)a2&quot; is a type =
 conversion in cast </span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0=A0 notation (=A75.4). &quot;a1 =3D =
 const_cast&lt;A1&gt;(a2)&quot; is </span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0=A0 ill-formed, but &quot;a1 =3D =
 static_cast&lt;A1&gt;(a2)&quot; is
 well-formed,</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0=A0 because &quot;a1 =3D A1(a2)&quot; is well-formed =
 (this is the exact</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0=A0 condition specified by =A75.2.9p2). Thus, for =
 =A75.4p5, the</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0=A0 cast notation is equivalent to the static_cast =
 notation.</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0=A0 The static_cast notation is then equivalent to =
 </span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0=A0 &quot;a1 =3D A1(a2)&quot;, which upcasts a2 to const =
 A&amp;
 implicitally,</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0=A0 and then invokes A1(const A&amp;). </span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0=A0 G++ behaves exactly as the standard prescribes, and =
 all</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0=A0 the other compilers I have agree.</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0 =A0If you need to force the use of the custom conversion =
 </span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0=A0 operator, you can still do it using the =
 syntax</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>=A0=A0=A0 &quot;a1 =3D a2.operator =
 A1()&quot;.</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>&nbsp;</span></font></p>
 
 <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span =
 style=3D'font-size:
 10.0pt'>http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=3Dview%20audittrail&a=
 mp;database=3Dgcc&amp;pr=3D4337</span></font></p>
 
 </div>
 
 </body>
 
 </html>
 
 ------_=_NextPart_001_01C31994.45348570--


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

* Re: c++/4337: [2003-01-01]c++ ignores cast operator
@ 2003-05-05  1:14 giovannibajo
  0 siblings, 0 replies; 3+ messages in thread
From: giovannibajo @ 2003-05-05  1:14 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, serge.bogdanov

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1005 bytes --]

Synopsis: [2003-01-01]c++ ignores cast operator

State-Changed-From-To: analyzed->closed
State-Changed-By: bajo
State-Changed-When: Mon May  5 01:14:02 2003
State-Changed-Why:
    Not a bug. "a1 = (A1)a2" is a type conversion in cast 
    notation (§5.4). "a1 = const_cast<A1>(a2)" is 
    ill-formed, but "a1 = static_cast<A1>(a2)" is well-formed,
    because "a1 = A1(a2)" is well-formed (this is the exact
    condition specified by §5.2.9p2). Thus, for §5.4p5, the
    cast notation is equivalent to the static_cast notation.
    The static_cast notation is then equivalent to 
    "a1 = A1(a2)", which upcasts a2 to const A& implicitally,
    and then invokes A1(const A&). 
    G++ behaves exactly as the standard prescribes, and all
    the other compilers I have agree.
    If you need to force the use of the custom conversion 
    operator, you can still do it using the syntax
    "a1 = a2.operator A1()".

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=4337


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

end of thread, other threads:[~2003-05-14  0:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-14  0:46 c++/4337: [2003-01-01]c++ ignores cast operator Giovanni Bajo
  -- strict thread matches above, loose matches on Subject: below --
2003-05-13 21:19 Bogdanov, Serge
2003-05-05  1:14 giovannibajo

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