[cfe-dev] -fcatch-undefined-behavior false positive with readdir()?
Sean McBride
sean at rogue-research.com
Wed Sep 26 07:29:58 PDT 2012
Hi all,
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:
-------------------
#include <dirent.h>
#include <stdio.h>
int main (void)
{
DIR* dir = opendir("/usr/lib");
if (dir)
{
struct dirent* d = NULL;
while ((d = readdir(dir)) != NULL)
{
const char* local = d->d_name; // bam!
printf ("%s\n", local);
}
closedir(dir);
}
return 0;
}
-------------------
$ clang --version
clang version 3.2 (trunk 164470)
$ clang -Weverything -fcatch-undefined-behavior test.c
(no output)
$ ./a.out
.
..
arc
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.
Thanks,
--
____________________________________________________________
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
mailing list