[cfe-dev] -fcatch-undefined-behavior false positive with readdir()?
sean at rogue-research.com
Wed Sep 26 07:29:58 PDT 2012
The following C code works without -fcatch-undefined-behavior, and worked with it too, until a few weeks ago when it was given new smarts:
int main (void)
DIR* dir = opendir("/usr/lib");
struct dirent* d = NULL;
while ((d = readdir(dir)) != NULL)
const char* local = d->d_name; // bam!
printf ("%s\n", local);
$ clang --version
clang version 3.2 (trunk 164470)
$ clang -Weverything -fcatch-undefined-behavior test.c
Illegal instruction: 4
Several colleagues have reviewed the code, and so I'm guess I'm asking if I should file a bug, or have missed something subtle here.
Sean McBride, B. Eng sean at rogue-research.com
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
More information about the cfe-dev