C++ Logo


Advanced search

Re: [ub] Sized integer types and char bits

From: Gabriel Dos Reis <gdr_at_[hidden]>
Date: Sun, 27 Oct 2013 12:08:48 -0500
John Regehr <regehr_at_[hidden]> writes:

| >> Wow-- anyone care to guess what fraction of existing C programs run
| >> correctly under these conditions?
| > Define correctly.
| A conforming program could be said to run correctly under a
| non-conforming C implementation if some test suite fails to find
| anything wrong with the program.
| For example it's not uncommon to see programs that use
| 1<<(sizeof(int)*CHAR_BIT-1) instead of INT_MIN. Any such program would
| be highly unlikely to run correctly on the 36-bit ones complement C
| implementation.

The C standards tend to use slightly different terminology than the C++
standards; and it is not always the case that a concept or an
operational model in C carries verbatim to C++ (or that it even has
meaning there).

For instance, the C++ standards dispensed with the notion of 'conforming
program' and focused instead only on the notion of conforming implementation.

Also, I can't help but to observe that it is quite important that we (I
mean collectively us, me first) be careful abouse uses of phrases like
"correct", "broken", "compiler breaking correct programs", etc. This is
a very sensitive area that requires caution; the issue is already
confusing enough without our help.

-- Gaby

Received on 2013-10-27 18:09:04