This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
"discards qualifiers" with no apparent cause
- To: gcc-bugs at gcc dot gnu dot org
- Subject: "discards qualifiers" with no apparent cause
- From: "L. Peter Deutsch" <ghost at aladdin dot com>
- Date: Wed, 1 Sep 1999 11:59:46 -0700
Environment: gcc 2.95.1 running on:
> Linux oquirrh.math.utah.edu 2.2.5-22 #1 Wed Jun 2 09:17:03 EDT 1999 i686 unknown
Symptom:
Many "discards qualifiers" messages with no apparent cause. gcc 2.7.2.3
does not produce these messages, so they're caused by something other than
discarding const. The test case is large and complex: Aladdin Ghostscript
5.91 from ftp://ftp.cs.wisc.edu/ghost/aladdin/test/ghostscript-5.91.tar.gz.
One place it occurs is (twice) on line 55 of gsfunc3.c, which, after
preprocessor expansion, reads:
static const gc_ptr_element_t function_ElIn_enum_ptrs [] = { { GC_ELT_OBJ, ((int) ( (char *)&(( gs_function_ElIn_t *)0)-> params.C0 - (char *)(( gs_function_ElIn_t *)0) )) } , { GC_ELT_OBJ, ((int) ( (char *)&(( gs_function_ElIn_t *)0)-> params.C1 - (char *)(( gs_function_ElIn_t *)0) )) } }; static const gc_struct_data_t function_ElIn_reloc_ptrs = { (sizeof( function_ElIn_enum_ptrs ) / sizeof(( function_ElIn_enum_ptrs )[0])) , 0 , & st_function , function_ElIn_enum_ptrs }; static const gs_memory_struct_type_t st_function_ElIn = { sizeof( gs_function_ElIn_t ), "gs_function_ElIn_t" , 0, 0, basic_enum_ptrs, basic_reloc_ptrs, 0 , & function_ElIn_reloc_ptrs } ;
Note that the only casts in this mess are applied to pointers derived from
0. gs_function_ElIn_t is a struct type: its params.C0 and params.C1 members
are declared as const float *, but casting a const float ** (the type of
&xxx->params.C0) to a char * does not discard any qualifiers (unlike casting
a const float *const * to a char *) any more than casting a float ** to a
char * does. Is that the problem? (I've run into other compilers that also
don't handle the distinction between const ** and const *const * properly.)
I can change the macro that generates the casts to use const char * rather
than char *, but this still looks like a bug to me, and it may crop up in
other places.
Thanks -
L. Peter Deutsch | Aladdin Enterprises :::: ghost@aladdin.com
203 Santa Margarita Ave. | tel. +1-650-322-0103 (AM only); fax +1-650-322-1734
Menlo Park, CA 94025 | http://www.cs.wisc.edu/~ghost/index.html