public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: "Bogdanov, Serge" <serge.bogdanov@intel.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org, Subject: RE: c++/4337: [2003-01-01]c++ ignores cast operator Date: Tue, 13 May 2003 21:19:00 -0000 [thread overview] Message-ID: <20030513211602.16723.qmail@sources.redhat.com> (raw) 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'> </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&pr=3D4337</span></font></p> <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span = style=3D'font-size: 10.0pt'> </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'> </span></font></p> <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span = style=3D'font-size: 10.0pt'>>>> 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&)'</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'> </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'> </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'> </span></font></p> <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span = style=3D'font-size: 10.0pt'>>> 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'> </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'> </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'> </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->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. "a1 =3D (A1)a2" 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). "a1 =3D = const_cast<A1>(a2)" 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 "a1 =3D = static_cast<A1>(a2)" 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 "a1 =3D A1(a2)" 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 "a1 =3D A1(a2)", which upcasts a2 to const = A& 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&). </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 "a1 =3D a2.operator = A1()".</span></font></p> <p class=3DMsoPlainText><font size=3D2 face=3D"Courier New"><span = style=3D'font-size: 10.0pt'> </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&pr=3D4337</span></font></p> </div> </body> </html> ------_=_NextPart_001_01C31994.45348570--
next reply other threads:[~2003-05-13 21:19 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-05-13 21:19 Bogdanov, Serge [this message] -- strict thread matches above, loose matches on Subject: below -- 2003-05-14 0:46 Giovanni Bajo 2003-05-05 1:14 giovannibajo
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20030513211602.16723.qmail@sources.redhat.com \ --to=serge.bogdanov@intel.com \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).