g++ 4.8 fails with -Ox option

Ian Lance Taylor iant@google.com
Sun Jul 21 19:34:00 GMT 2013


On Fri, Jul 19, 2013 at 5:27 AM, Patrick Begou
<Patrick.Begou@legi.grenoble-inp.fr> wrote:
>
> I get a strange problem with g++ 4.8. My server has gcc44-c++-4.4.1
> installed.
> I've installed gcc4.8 in my home from gcc-4.8-20130711.tar.gz
> gcc-4.8-infrastructure.tar.gz.
> PATH, LD_LIBRARY_PATH are setup to reach first this 4.8 install.
>
> Initially I get the error runing the configure script to build OpenMPI, so I
> extract the small peace of test code in "prog.C" file for testing and:
>
> g++ -o conftest -DNDEBUG -finline-functions prog.C
> Is working but:
> g++ -o conftest -O3 -DNDEBUG -finline-functions prog.C
> says:
>
> In file included from /usr/include/stdio.h:909:0,
> from prog.C:141:
> /usr/include/bits/stdio.h: In function ‘__ssize_t getline(char**, size_t*,
> FILE*)’:
> /usr/include/bits/stdio.h:118:52: error: ‘__getdelim’ was not declared in
> this scope
> return __getdelim (__lineptr, __n, '\n', __stream);
>
> Same behavior with -O2 or -O1.
> g++ 4.8 works with -O0.
>
> I've no idea about this problem. Thanks for your advices.

Using optimization changes how your library header files behave.  Look
for #ifdef __OPTIMIZE__ or defined(__OPTIMIZE__).  This looks like a
problem with your C library, not with GCC proper.

Ian



More information about the Gcc-help mailing list