This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Built-in attribute table and host header files polluting it


NetBSD's <stdio.h> has the following block of code:

/*
 * This is a #define because the function is used internally and
 * (unlike vfscanf) the name __svfscanf is guaranteed not to collide
 * with a user function when _ANSI_SOURCE or _POSIX_SOURCE is defined.
 */
#define  vfscanf        __svfscanf

This presents a problem when building GCC.  What happens is that
when the built-in attribute table is built, the scanf format attribute
that is supposed to be applied to "vfscanf" ends up being applied
to "__svfscanf", because <stdio.h> has been slurped in by one of the
headers somewhere.

This results in testsuite failures:

FAIL: gcc.dg/format/c99-scanf-3.c vfscanf (test for warnings, line 21)
FAIL: gcc.dg/format/c99-scanf-3.c vfscanf (test for warnings, line 21)
FAIL: gcc.dg/format/ext-6.c vfscanf (test for warnings, line 42)
FAIL: gcc.dg/format/ext-6.c vfscanf (test for warnings, line 42)

...changing those call sites to __svfscanf causes the tests to pass.

Now, I'm not saying that what NetBSD's <stdio.h> is doing is right
(in fact, I'm pretty sure it's wrong ... it should be just using
a weak symbol there, but it's not for hysterical raisins).  But it
makes me wonder if the built-in attribute tables shouldn't be built
in a more protected environment (separate file from c-common.c, with
minimal host system include files pulled in) to avoid this sort of
thing in the first place...

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]