Opened 12 years ago

Closed 12 years ago

Last modified 8 years ago

#1533 closed defect (fixed)

mm.cc fails to build with GCC 4.7

Reported by: volter Owned by: grass-dev@…
Priority: major Milestone: 6.4.2
Component: Compiling Version: 6.4.1
Keywords: libiostream, r.terraflow, gcc4.7, iostream, gcc, -fexceptions, throw Cc:
CPU: Unspecified Platform: Unspecified

Description

mm.cc: In function 'void* operator new [](size_t)':
mm.cc:259:32: error: declaration of 'void* operator new [](size_t)' has a different exception specifier
In file included from mm.cc:29:0:
/builddir/build/BUILD/grass-6.4.1/dist.x86_64-redhat-linux-gnu/include/grass/iostream/mm.h:114:17: error: from previous declaration 'void* operator new [](std::size_t) throw (std::bad_alloc)'
mm.cc: In function 'void* operator new(size_t)':
mm.cc:310:30: error: declaration of 'void* operator new(size_t)' has a different exception specifier
In file included from mm.cc:29:0:
/builddir/build/BUILD/grass-6.4.1/dist.x86_64-redhat-linux-gnu/include/grass/iostream/mm.h:113:17: error: from previous declaration 'void* operator new(std::size_t) throw (std::bad_alloc)'
mm.cc: In function 'void operator delete(void*)':
mm.cc:362:32: error: declaration of 'void operator delete(void*)' has a different exception specifier
In file included from mm.cc:29:0:
/builddir/build/BUILD/grass-6.4.1/dist.x86_64-redhat-linux-gnu/include/grass/iostream/mm.h:115:15: error: from previous declaration 'void operator delete(void*) throw ()'
mm.cc: In function 'void operator delete [](void*)':
mm.cc:402:34: error: declaration of 'void operator delete [](void*)' has a different exception specifier
In file included from mm.cc:29:0:
/builddir/build/BUILD/grass-6.4.1/dist.x86_64-redhat-linux-gnu/include/grass/iostream/mm.h:116:15: error: from previous declaration 'void operator delete [](void*) throw ()'
make[3]: *** [OBJ.x86_64-redhat-linux-gnu/mm.o] Error 1

Change History (5)

comment:1 by hamish, 12 years ago

Keywords: libiostream r.terraflow gcc4.7 added

comment:2 by glynn, 12 years ago

The log doesn't include the actual compilation command. Assuming that this is the issue originally reported in #1532, the command is:

c++ -I/builddir/build/BUILD/grass-6.4.1/dist.x86_64-redhat-linux-gnu/include  -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4  -m64 -mtune=generic   -D_FILE_OFFSET_BITS=64   -DPACKAGE=\""grasslibs"\"  -I/builddir/build/BUILD/grass-6.4.1/dist.x86_64-redhat-linux-gnu/include -o OBJ.x86_64-redhat-linux-gnu/mm.o -c mm.cc

I suspect that it's the -fexceptions which is causing the error. lib/iostream and r.terraflow neither throw nor catch exceptions, so there isn't actually any reason to use -fexceptions (either way, any exception will just terminate the program). OTOH, the exception specifications are part of the signature of the new and delete operators, so they should be present. Try r50130 from trunk; if there are no issues, it should be back-ported.

comment:3 by martinl, 12 years ago

Resolution: fixed
Status: newclosed

Seems to be already backported. Closing this ticket.

comment:4 by wenzeslaus, 8 years ago

In 68818:

use exception specifiers only for C++ versions older than C++11

Tested using GCC 5.2.1.

No exception specifiers (throw(...)) fail with -std=c++98 -fexceptions.
Omitting noexcept (or throw()) fails with -std=c++11 and -std=c++14.

Using cplusplus to get C++ standard version which defines
how the definitions in the standard library look like
and using GRASS_MM_USE_EXCEPTION_SPECIFIER we then use the right ones.

This contains old fix for -fexceptions with GCC 4.7 (see #1533, r50130)
and new fix for GCC 6 where -std=gnu++14 is by default (see #2871
and Debian Bug 811886).

Works also with clang++ -std=c++14.

comment:5 by wenzeslaus, 8 years ago

Keywords: iostream gcc -fexceptions throw added
Note: See TracTickets for help on using tickets.