M
Mike Wahler
Arthur J. O'Dwyer said:Depends what you mean. My computer is physically incapable of
producing "undefined" byte values, so my source code is always
well-defined. Of course, if one of my programs violates a
constraint, then my C compiler issues a diagnostic and refuses
to compile the code, as required and allowed, respectively, by
the Standard. So there does not exist any "program", nor any
"behavior", defined or otherwise, associated with a program
which is not correct C. IMHO.
'Course not! The error would specify (if I'm lucky) which
constraint had been violated, so I could fix it.
That doesn't make sense. A "C program" which does not compile
is not, technically speaking, a C program. It's *almost* a
program, but if it's not something that a C compiler can accept,
then I wouldn't call it a C program. And in this newsgroup, we
only talk about the "(un)defined behavior" of C programs.
Did you? Sorry.
How does that invoke UB?
6.4 Lexical elements
Constraints
2 Each preprocessing token that is converted to a token shall
have the lexical form of a keyword, an identifier, a constant,
a string literal, or a punctuator.
Semantics
3 A token is the minimal lexical element of the language in
translation phases 7 and 8. The categories of tokens are:
keywords, identifiers, constants, string literals, and
punctuators. A preprocessing token is the minimal lexical
element of the language in translation phases 3 through 6.
The categories of preprocessing tokens are: header names,
identifiers, preprocessing numbers, character constants,
string literals, punctuators, and single non-white-space
characters that do not lexically match the other preprocessing
token categories. If a ' or a " character matches the last
category, the behavior is undefined. Preprocessing tokens <<<=====
can be separated by white space; this consists of comments
(described later), or white-space characters (space, horizontal
tab, new-line, vertical tab, and form-feed), or both. As
described in 6.10, in certain circumstances during translation
phase 4, white space (or the absence thereof) serves as more
than preprocessing token separation. White space may appear
within a preprocessing token only as part of a header name
or between the quotation characters in a character constant
or string literal.
In fact, how exactly does that violate
a constraint?
AFAICT it doesn't.
I'm having a hard time reading the Standard tonight;
I know there's some prohibition about unterminated character constants
in there somewhere, but I can't find it...
See above.
-Mike