[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bison struniq const violates C Standard
From: |
Paul Eggert |
Subject: |
Bison struniq const violates C Standard |
Date: |
Tue, 12 Nov 2002 22:30:06 -0800 (PST) |
I checked in the following patch. The 'const' violates the C
standard. GCC supports 'const' here as an extension, so perhaps
that's what was intended, but I don't think the function satisfies the
GCC 'const' constraint, since the function has side effects.
(This confusion is yet another reason to always put 'const' _after_
the type that it modifies, not before -- but that is another story.)
2002-11-12 Paul Eggert <address@hidden>
* src/struniq.h (struniq_new): Do not declare the return type
to be 'const'; this violates the C standard.
* src/struniq.c (struniq_new): Likewise.
Index: src/struniq.c
===================================================================
RCS file: /cvsroot/bison/bison/src/struniq.c,v
retrieving revision 1.2
diff -p -u -r1.2 struniq.c
--- src/struniq.c 12 Nov 2002 08:05:59 -0000 1.2
+++ src/struniq.c 13 Nov 2002 06:24:18 -0000
@@ -37,7 +37,7 @@ static struct hash_table *struniqs_table
| Create the struniq for S if needed. |
`-------------------------------------*/
-const struniq_t
+struniq_t
struniq_new (const char *s)
{
struniq_t res = hash_lookup (struniqs_table, s);
Index: src/struniq.h
===================================================================
RCS file: /cvsroot/bison/bison/src/struniq.h,v
retrieving revision 1.2
diff -p -u -r1.2 struniq.h
--- src/struniq.h 12 Nov 2002 08:05:59 -0000 1.2
+++ src/struniq.h 13 Nov 2002 06:24:18 -0000
@@ -28,7 +28,7 @@
typedef const char *struniq_t;
/* Return the struniq for S. */
-const struniq_t struniq_new (const char *s);
+struniq_t struniq_new (const char *s);
/* Two struniq have the same value iff they are the same. */
#define STRUNIQ_EQ(S1, S2) ((S1) == (S2))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Bison struniq const violates C Standard,
Paul Eggert <=