freebsd / atf

Libraries to write tests in C, C++ and shell
Other
133 stars 45 forks source link

Use __uintptr_t in place of unsigned long in UNCONST() macros. #24

Closed brooksdavis closed 7 years ago

brooksdavis commented 8 years ago

The C language only guarantees that pointers can be reconstituted after being cast to an integral type if that type if that type is (u)intptr_t.

jmmv commented 8 years ago

(I took the original UNCONST implementation from the original NetBSD headers so didn't question it much.)

But about your change: if the cast should be against uintptr_t, why does the code say __uintptr_t? Note that the tests are failing.

brooksdavis commented 8 years ago

__uintptr_t is define by the compiler and thus is more appropriate for a normal UNCONST macro in a system header since it has no dependencies. In practice uintptr_t should be fine and might be more appropriate here.

I see about 30 test failures with and without this change on FreeBSD 10.2. In Travis CI, it looks like there's an explicit exit 2 in the script somewhere which is triggering failures here.

jmmv commented 8 years ago

You have to scroll up (before the dump of the config.log contents) to see the actual build error.

brooksdavis commented 8 years ago

It looks like the previous versions were working due to header pollution on FreeBSD (both clang and gcc5 built without warnings without stdint.h included).