C++ Logo


Advanced search

Re: [wg14/wg21 liaison] UB

From: Hans Boehm <boehm_at_[hidden]>
Date: Fri, 26 May 2023 09:06:15 -0700
There are currently also a few more not-obviously-localized forms of
undefined behavior, even in the C standard. In N3096, I found

 footnote 92 (header names)

restrict seems tricky, buit can probably be handled like data races?

"The execution of a non-directive preprocessing directive results in
undefined behavior."

Referring to signal(): "Use of this function in a multi-threaded program
results in undefined behavior." Actually, I don't understand why that's
there at all. I could see "implementation defined". As it stands, if I call
signal(), and then create threads, it encounters undefined behavior at the
first thread creation? Do we guarantee that the standard library doesn't
create threads behind the scenes?

H.13: "Use of the macro with an argument of a decimal floating type results
in undefined behavior." This seems likely to be diagnosed way ahead of
executing it.

A bunch of the J.2 undefined behaviors, like "A nonempty source file does
not end in a new-line character which is not immediately preceded by a
backslash character or ends in a partial preprocessing token or comment
(" are purely static code properties.


Received on 2023-05-26 16:06:29