Should the following code have a warning? It has undefined behavior if argc == 0.
int main(int argc, char **argv) { return **argv; }
> refuse to compile/use implementation-defined behaviour (i.e. exactly "what the hardware does")
malloc is guaranteed to be 16-byte aligned on macOS. Should the following code not compile?
void *memalign(size_t size, size_t alignment) { #if TARGET_OS_MAC if (alignment < 16) { return malloc(size); } #endif // General case }
Should the following code have a warning? It has undefined behavior if argc == 0.
As you can see, alerting for potential undefined behavior is a very difficult problem to do in a way that doesn't cause a bunch of spurious issues.> refuse to compile/use implementation-defined behaviour (i.e. exactly "what the hardware does")
malloc is guaranteed to be 16-byte aligned on macOS. Should the following code not compile?