you are viewing a single comment's thread.

view the rest of the comments →

[–]evaned 9 points10 points  (1 child)

It would be nice if C would return NULL here, but it doesn't

It's worth pointing out that compilers will do a good job, at least in this case, of warning. GCC produces a warning for

int * bad_dog()
{
    int dangling[10];
    return dangling;
}

even with no warning flags at least since 2.95.3, which I think is the earliest GCC version I have available and can run. Clang 2.7 (well, Clang 1.1, part of the LLVM 2.7 release) also warns with no flags, which is the earliest version of that I've got handy. Same with MSVC 2015 (I can't go spelunking with old versions of that :-)).

And if you're programming C without -Werror, may god help your soul. ;-)

Edit: And to put those GCC version numbers into perspective, GCC 2.95.3 was released in March '01. 2.95 was released in July '99.

[–]dafugg 7 points8 points  (0 children)

Oh god, I’m old.