Bug 103017
| Summary: | New glibc make assert() in C++ with pointer uncompilable. | ||
|---|---|---|---|
| Product: | [Retired] Red Hat Raw Hide | Reporter: | John Eckerdal <john.eckerdal> |
| Component: | glibc | Assignee: | Jakub Jelinek <jakub> |
| Status: | CLOSED DUPLICATE | QA Contact: | Brian Brock <bbrock> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 1.0 | CC: | fweimer, hugh |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | i386 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2006-02-21 18:58:13 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
*** This bug has been marked as a duplicate of 102916 *** perhaps this bug is related: <https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=127606> Changed to 'CLOSED' state since 'RESOLVED' has been deprecated. |
From Bugzilla Helper: User-Agent: Opera/7.20 (X11; Linux i686; U) [en] Description of problem: The new glibc (or GCC, not sure) makes it impossible to compile programs which use assert when checking pointers. I first noticed this problem in ScummVM which uses C++ and then I tried to compile ClanLib (also C++) and the same problem is there also. As far as I understand it is legit to assert() with pointers. Example program: #include <stdio.h> #include <assert.h> typedef unsigned char byte; int main(void) { int* nisse1 = NULL; byte* nisse2 = NULL; assert(nisse1); assert(nisse2); return 0; } Compile this with: g++ -Wall -o test test.cc test.cc: In function `int main()': test.cc:10: error: invalid conversion from `int*' to `long int' test.cc:11: error: invalid conversion from `byte*' to `long int' Same program with gcc (not C++): gcc -o test test.c test.c: In function `main': test.c:10: warning: passing arg 1 of `__builtin_expect' makes integer from pointer without a cast test.c:11: warning: passing arg 1 of `__builtin_expect' makes integer from pointer without a cast If I change the program to #include <stdio.h> #include <assert.h> typedef unsigned char byte; int main(void) { int* nisse1 = NULL; byte* nisse2 = NULL; assert(nisse1 != NULL); assert(nisse2 != NULL); return 0; } It works fine. It seems like this problem is related to the addition of __builtin_expect in the assert.h file provided by glibc. This function takes a long in, and C++ will fail to cast a pointer to a long. C will produce a warning. Version-Release number of selected component (if applicable): glibc-2.3.2-71 How reproducible: Always Steps to Reproduce: 1. Enter the first testsnippet in an editor 2. Try to compile (g++ -o test test.cc) 3. See it fail to compile Actual Results: The programs did not compile Expected Results: That the programs should compile. Additional info: Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.3.1/specs Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux Thread model: posix gcc version 3.3.1 20030814 (Red Hat Linux 3.3.1-2)