Defect Report #133
Submission Date: 03 Dec 93
Submittor: WG14
Source: Project Editor (P.J. Plauger)
Question
Undefined behavior not previously listed in subclause G2:
1. Applying sizeof to an enumerate type, as in
enum f {c = sizeof (enum f)}
has undefined behavior.
2. A program containing no function called main
has undefined behavior.
3. A storage class specifier or type-qualifier modifying the keyword
void as a function parameter-type-list has undefined
behavior.
4. Indexing an array beyond its specified size, as in:
int a[4][5];
a[1][7] = 0;
has undefined behavior.
5. If a ``shall'' or ``shall not'' requirement that appears
outside of a constraint is violated, the behavior is undefined.
6. In pointer-integer conversion, the size of integer required and
the result are implementation-defined. If the space provided is not
long enough, the behavior is undefined.
7. The result of the % operator is the remainder. In both this
and the divide operations, if the value of the second operand is zero,
the behavior is undefined.
8. As with any other arithmetic overflow, if the result does not fit
in the space provided, the behavior is undefined.
9. If a file with the same name as a standard header, not provided
as part of the implementation, is placed in any of the standard places
for a source file to be included, the behavior is undefined.
10. If the signal handler func(int sig) executes a return
statement and the value of sig was SIGFPE or any other
implementation-defined value corresponding to a computational exception,
the behavior is undefined.
11. If any signal is generated by an asynchronous signal handler,
the behavior is undefined.
12. If copying takes place between objects that overlap, the behavior
is undefined.
13. If a fully expanded macro replacement list contains a function-like
macro name as its last preprocessing token, it is unspecified whether
this macro name may be subsequently replaced. If the behavior of the
program depends upon this unspecified behavior, then the behavior
is undefined. For example:
#define f(a) a*g
#define g(a) f(a)
the invocation f(2) (9) results in undefined behavior.
14. A call to a library function that exceeds an Environmental limit
has undefined behavior.
Response
The C Standard makes it sufficiently clear that the described behaviors
are undefined. The next revision of the C Standard can include a more
comprehensive list.
Previous Defect Report
< - >
Next Defect Report