Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on “What the Hardware Does” Is Not What Your Program Does: Uninitialized Memory. Parent comment
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 }
There are no comments on this comment yet.
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?