This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug math/10415] New: Compiler error when compiling test-tgmath2.c with gcc 4.5.0 (20090717) + fix
- From: "dps at simpson dot demon dot co dot uk" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 19 Jul 2009 18:39:43 -0000
- Subject: [Bug math/10415] New: Compiler error when compiling test-tgmath2.c with gcc 4.5.0 (20090717) + fix
- Reply-to: sourceware-bugzilla at sourceware dot org
This bug also affects the i686-pc-linux-gnu target and probably most other
targets In make check gcc 4.5.0 says:
test-tgmath2.c: In function ?test?:
test-tgmath2.c:167:3: error: assignment of read-only variable ?texpr?
test-tgmath2.c:168:3: error: assignment of read-only variable ?texpr?
test-tgmath2.c:169:3: error: assignment of read-only variable ?texpr?
test-tgmath2.c:178:3: error: assignment of read-only variable ?texpr?
test-tgmath2.c:179:3: error: assignment of read-only variable ?texpr?
My diagnosis that __typeof__ (expr) texpr declares texpr to be const in those
tests, so the assignment further down in the TEST2 macro produces an error message.
The following patch uses mixed declarations and code to eliminate the
assignment, which fixes the problem. It might be nice if the compiler supported
declaring a variable as const and allowing a single assignment to it sometime later.
--- math/test-tgmath2.c.dist 2009-07-19 17:22:48.664507445 +0100
+++ math/test-tgmath2.c 2009-07-19 19:24:45.952008134 +0100
@@ -120,13 +120,12 @@
#define TEST2(expr, type, rettype, fn) \
do \
{ \
- __typeof__ (expr) texpr = 0; \
TEST_TYPE_ONLY (expr, rettype); \
if (count != 0) \
FAIL ("internal error"); \
if (counts[T##type][C_##fn] != 0) \
FAIL ("internal error"); \
- texpr = expr; \
+ __typeof__ (expr) texpr = expr; \
__asm __volatile ("" : : "r" (&texpr)); \
if (count != 1 || counts[T##type][C_##fn] != 1) \
{ \
--
Summary: Compiler error when compiling test-tgmath2.c with gcc
4.5.0 (20090717) + fix
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: math
AssignedTo: aj at suse dot de
ReportedBy: dps at simpson dot demon dot co dot uk
CC: glibc-bugs at sources dot redhat dot com
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=10415
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.