3 ms·
> So the lack of soundness is in the C++ templates spec. That's not a lack of soundness. It's a lack of specificity. For cases like this, that's actually a fea
by cbsmith 13y ago
> So the lack of soundness is in the C++ templates spec.
That's not a lack of soundness. It's a lack of specificity. For cases like this, that's actually a feature, not a bug.
> Nevertheless, I think it's bad form for a compiler to take full advantage of undefined behaviour.
What exactly is "take full advantage of undefined behaviour"? Isn't any behaviour just as different from "undefined" as anything else?
> Reinterpreting undefined behaviour as “should not compile” (failing that, “must crash”) is possible for almost all of C99; CompCert (formally verified C compiler) obviously does it, and the implementation is the easy part (formal verification being the complicated part).
Clang not only has an ability to do this, it includes a flag to do a quick check specifically for undefined behaviour as well as an ability to provide a trap for undefined behaviour, which is terribly useful for tool builders.