Defect Report: "string-literal" used where narrow string literal is possibly intended

Defect Report: "string-literal" used where narrow string literal is possibly intended

Post by gennaro_pr » Thu, 14 Sep 2006 08:35:24


There are several places in the standard where a string-literal is
said to be required but it is at best dubious whether a wide string
literal is actually allowed:

* 7 [dcl.dcl]/1 and 7 [dcl.dcl]/4: respectively grammar and
description for static_assert-declaration

* 7.4 [dcl.asm]/1: the asm declaration

* 7.5 [dcl.link]/1: linkage specifications

* 8.5.2 [dcl.init.string]/1:

"A char array (whether plain char, signed char, or unsigned char)
can be initialized by a string-literal (optionally enclosed in
braces)"

This should clearly be "A char array (whether plain char, signed
char, or unsigned char) can be initialized by a narrow
string-literal"

* 16.3.2 [cpp.stringize]/2:

"If, in the replacement list, a parameter is immediately preceded
by a # preprocessing token, both are replaced by a single
character string literal preprocessing token that contains the
spelling of the preprocessing token sequence for the
corresponding argument."

16.4 [cpp.line]/1:

"The string literal of a #line directive, if present, shall be a
character string literal."

This seems a terminology problem: does "character string literal"
stand for "narrow string literal"? Also, I can see an almost
random switching between the forms "string-literal", which a
hyphen, and "string literal". Maybe some editorial fix is in
order.

16.8 [cpp.predefined]/1:

"__FILE__
The presumed name of the source file (a character string
literal).

These three preprocessing cases should IMHO all be clarified.

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.yqcomputer.com/ ]
 
 
 

Defect Report: "string-literal" used where narrow string literal is possibly intended

Post by fgothamN » Thu, 14 Sep 2006 11:45:11

Gennaro Prota posted:



Perhaps it would be more convenient to write:

Unless explicitly described as a wide string literal, any mention of a
string literal in this International Standard refers to a narrow string
literal.

--

Frederick Gotham

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.yqcomputer.com/ ]

 
 
 

Defect Report: "string-literal" used where narrow string literal is possibly intended

Post by Greg Herli » Thu, 14 Sep 2006 16:39:48


Narrow string literals are also called "ordinary" string literals -
which means that the plain term "string literal" can be taken to mean a
narrow string literal.

Now the term "string-literal" (note the hyphen) is a specific
production of the C++ grammar (which is why the term is italicized).
Furthermore, the "string-literal" production encompasses both narrow
and wide string literals. So it is not the case that the Standard is
randomly varying the spelling of "string literal" because it is unsure
which variation is correct. On the contrary, the two terms are distinct
- one is a generic term for a program's constant character data and the
other is a specific production of the C++ language.

Greg

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.yqcomputer.com/ ]
 
 
 

Defect Report: "string-literal" used where narrow string literal is possibly intended

Post by gennaro_pr » Thu, 14 Sep 2006 21:39:58

On Wed, 13 Sep 2006 02:45:11 GMT, XXXX@XXXXX.COM (Frederick



Hmm... in general I don't like these sorts of sentences: they are
almost always too far from any point they refer to, for little benefit
(the standard, just like source code, is read a considerable higher
number of times than it is written :-O).

<meta (to mods)>

A while ago defect report posts which were accepted by the
moderator carried a note along the lines of "forwarded to
the C++ committee". I notice this is no more the case. Are
they silently forwarded? (Last time this happened I verified
that it had *not* been forwarded)

</meta>

---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.yqcomputer.com/ ]