Standard headers give compile-time error at -O2

Matt Austern austern@isolde.engr.sgi.com
Wed Dec 22 17:57:00 GMT 1999


This isn't really an optimizer bug.  -O2 makes a difference
only because it defines a couple of macros and changes the
preprocessed source.

System: i686 linux (2.2 kernel, glibc 2.1)
Compiler: gcc version 2.96 19991114

Here's the symptom:
austern@pizzelle% cat ct.cc
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>


int main() {}
austern@pizzelle% gcc -c -O ct.cc
In file included from ct.cc:3:
/usr/include/stdlib.h:474: declaration of `void *malloc (unsigned int) throw
()' throws different exceptions
/usr/include/malloc.h:90: to previous declaration `void *malloc (unsigned int)'
/usr/include/stdlib.h:476: declaration of `void *calloc (unsigned int, unsigned
int) throw ()' throws different exceptions
/usr/include/malloc.h:93: to previous declaration `void *calloc (unsigned int,
unsigned int)'
/usr/include/stdlib.h:482: declaration of `void *realloc (void *, unsigned int)
throw ()' throws different exceptions
/usr/include/malloc.h:97: to previous declaration `void *realloc (void *,
unsigned int)'
/usr/include/stdlib.h:484: declaration of `void free (void *) throw ()' throws
different exceptions
/usr/include/malloc.h:100: to previous declaration `void free (void *)'
/usr/include/stdlib.h:488: declaration of `void cfree (void *) throw ()' throws
different exceptions
/usr/include/malloc.h:103: to previous declaration `void cfree (void *)'
In file included from ct.cc:3:
/usr/include/stdlib.h:497: declaration of `void *valloc (unsigned int) throw
()' throws different exceptions
/usr/include/malloc.h:109: to previous declaration `void *valloc (unsigned
int)'
austern@pizzelle%


Note that (1) stdio.h must be included for the problem to manifest
itself; and (2) -O2 is necessary, at least for the preprocessor.
Once I've generated preprocessed source, it doesn't matter whether I
compile the preprocessed source with -O or not.

I'm attaching compressed preprocessed source, generated with -E and
compressed with bzip2.  The preprocessed source is 4000 lines long;
I've made no attempt to pare it down.

			--Matt Austern
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ct.i.bz2
Type: application/x-bzip2
Size: 5335 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-bugs/attachments/19991222/06e1f23a/attachment.bz2>


More information about the Gcc-bugs mailing list