public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/3974: GCC 3.0 - ternary operator and "const char *"
@ 2001-08-10 13:09 aoliva
  0 siblings, 0 replies; 2+ messages in thread
From: aoliva @ 2001-08-10 13:09 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, tkarkanis

Synopsis: GCC 3.0 - ternary operator and "const char *"

State-Changed-From-To: open->closed
State-Changed-By: aoliva
State-Changed-When: Fri Aug 10 13:09:28 2001
State-Changed-Why:
    Yep, just like mandated by the C++ Standard.  String literals may be implicitly converted to type char*, but since operands 2 and 3 of the ternary operator have type const char[], they decay to const char *, and then, the result of the ternary operator cannot be converted to char*.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3974&database=gcc


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

* c++/3974: GCC 3.0 - ternary operator and "const char *"
@ 2001-08-09  7:46 tkarkanis
  0 siblings, 0 replies; 2+ messages in thread
From: tkarkanis @ 2001-08-09  7:46 UTC (permalink / raw)
  To: gcc-gnats

>Number:         3974
>Category:       c++
>Synopsis:       GCC 3.0 - ternary operator and "const char *"
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 09 07:46:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Tasso Karkanis
>Release:        gcc version 3.0
>Organization:
>Environment:
GNU/Linux (Red Hat 6.2 i386)
>Description:
When compiling the attached file with "g++ -c const.cpp",
the compiler emits for line 6 (with the ternary operator)
but not for line 5.  Somehow, when a string literal is
evaluated by the ternary operator, the type comes out as
"const char *", but otherwise, they are silently converted
to "char *".
>How-To-Repeat:
Compile the attached file with any options you want.
>Fix:
Rewrite the ternary operator with an if-statement and a
temporary variable of type "char *".
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="const.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="const.cpp"

ZXh0ZXJuIHZvaWQgZ29vKCBjaGFyICogKTsKCnZvaWQgbW9vKCBib29sIGIgKQp7CiAgICBnb28o
ICJhIiApOwogICAgZ29vKCBiID8gImEiIDogImIiICk7Cn0K


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

end of thread, other threads:[~2001-08-10 13:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-10 13:09 c++/3974: GCC 3.0 - ternary operator and "const char *" aoliva
  -- strict thread matches above, loose matches on Subject: below --
2001-08-09  7:46 tkarkanis

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