Re:Everything I wish I knew when learning C
by kmm01 on Monday November 28, 2022 @01:14PM
(#33777224)
The C standard defines them very differently though:
Implementations need not but may obviously assume that undefined behavior does not happen. Assume that however the program behaves if undefined behavior is invoked is how the compiler chose to implement that case.
[ Parent
| on HN ]
Re:Everything I wish I knew when learning C
by marssaxman on Monday November 28, 2022 @05:50PM
(#33781020)
"Nonportable" is a significant element of this definition. A programmer who intends to compile their C program for one particular processor family might reasonably expect to write code which makes use of the very-much-defined behavior found on that architecture: integer overflow, for example. A C compiler which does the naively obvious thing in this situation would be a useful tool, and many C compilers in the past used to behave this way. Modern C compilers which assume that the programmer will never intentionally write non-portable code are.... less helpful.