3 ms·
For an easy example, consider the following function: int next(int x) { return x + 1; } This invokes undefined behavior in the case where x = INT_MAX. Yet
by mikeash 12y ago
For an easy example, consider the following function:
int next(int x) { return x + 1; }
This invokes undefined behavior in the case where x = INT_MAX. Yet if this produced a compile-time diagnostic, it would be tremendously irritating and generally useless. Worse than useless, as it would swamp real diagnostics.