[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: bug in gcc?
- From: David Given <dg@...>
- Date: Wed, 04 Apr 2007 22:54:39 +0100
Roberto Ierusalimschy wrote:
> At least in C, the standard defines that the type of a string literal is
> "char*" (not const). But it also states that any attempt to modify the
> contents of a string literal has undefined behavior...
That's correct for C (well, actually it's an array of char), but not for C++,
where it's an array of const char, *except* in this one particular
circumstance. The relevant bits are 18.104.22.168:
...which describes string literals in general, and 4.2.2:
...where it describes the implicit casting behaviour. It's strictly for
compatibility with C, and is labeled DEPRECATED in large letters.
Nevertheless, I don't imagine it's going away any time soon...
┌── ｄｇ＠ｃｏｗｌａｒｋ．ｃｏｍ ─── http://www.cowlark.com ───────────────────
│ "Parents let children ride bicycles on the street. But parents do not
│ allow children to hear vulgar words. Therefore we can deduce that cursing
│ is more dangerous than being hit by a car." --- Scott Adams
Description: OpenPGP digital signature