This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: The treatment of null characters in C source files


>> But, surely there's no requirement that a C *source file* be allowed to
>> have a null character in it.
> Oh, I mis-understood.  Sorry.  No clue what the standard says here.

Section 5.2.1 (Character sets) requires the basic source character set to
have the usual bunch of alphanumerics and punctuation, and space, HT, VT,
FF, and "some way of indicating the end of each line of text".  Outside
of char and string literals and a few other places, encountering anything
else (eg, NUL) is undefined.  Inside a char constant or string literal:

	[...] members of the execution character set shall be represented
	by corresponding members of the source character set or by escape
	sequences [...]

The next sentence requires there to be a NUL character in the basic
execution character set, but not in the source one.

That section then refers you to 6.1.4 for string literals, which doesn't
really say anything about NULs, although there is an obliquely relevant
footnote:

	A character string literal need not be a string (sec 7.1.1), because
	a null character may be embedded in it by a \0 escape sequence.

So I don't think we're required to understand real NUL characters.
(I didn't look in the C++ standard, though.)

    John  "lawyers 'r' us :-)"


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]