#255 GCC 4.5 issues (was: compile error gdl-0.9rc4 with gcc45)


compiling for -m32 (implicit) with gcc45 on Apple Darwin 9.8 aka Leopard 10.5.8

/opt/local/bin/g++-mp-4.5 -DHAVE_CONFIG_H -I. -I../../gdl-0.9rc4/src -I.. -I/opt/local/include -I/opt/local/include -I/opt/local -I/opt/local/include -I/opt/local/include -I/opt/local/include/ImageMagick -I/opt/gdl/include -I/opt/gdl/include -I/opt/gdl/include/hdf -I/opt/gdl/include -I/opt/gdl/include/hdf -I/opt/gdl/include/hdf5 -I/opt/gdl/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -fopenmp -O2 -I/opt/local/include/python2.6 -DH5_USE_16_API=1 -I/opt/local/include/ImageMagick -DPJ_LIB__ -c -o gdl-math_fun_jmg.o `test -f 'math_fun_jmg.cpp' || echo '../../gdl-0.9rc4/src/'`math_fun_jmg.cpp
../../gdl-0.9rc4/src/math_fun.cpp: In function 'BaseGDL* lib::abs_fun_template(BaseGDL*) [with T = Data_<SpDInt>]':
../../gdl-0.9rc4/src/math_fun.cpp:1167:39: instantiated from here
../../gdl-0.9rc4/src/math_fun.cpp:1106:2: error: call of overloaded 'abs(Data_<SpDInt>::Ty&)' is ambiguous
/usr/include/stdlib.h:146:6: note: candidates are: int abs(int)
../../gdl-0.9rc4/src/math_utl.hpp:26:10: note: T abs(T) [with T = short int]
/opt/local/include/gcc45/c++/cstdlib:170:3: note: long long int __gnu_cxx::abs(long long int)
/opt/local/include/gcc45/c++/cstdlib:139:3: note: long int std::abs(long int)
/opt/local/include/gcc45/c++/cmath:108:5: note: typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type std::abs(_Tp) [with _Tp = short int, typename __gnu_cxx::__enable_if<std::__is_integer<_Tp>::__value, double>::__type = double]
/opt/local/include/gcc45/c++/cmath:102:3: note: long double std::abs(long double)
/opt/local/include/gcc45/c++/cmath:98:3: note: float std::abs(float)
/opt/local/include/gcc45/c++/cmath:94:3: note: double std::abs(double)
make[3]: *** [gdl-math_fun.o] Error 1

$ /opt/local/bin/g++-mp-4.5 --version
g++-mp-4.5 (GCC) 4.5.0 20100114 (experimental)

NASA is using gcc45 with SeaDAS, so we would like to build gdl with the same version.


  • A suggested fix is to use #define abs(x) (std::abs((x))) in math_utl.hpp

    The compile finishes, but I get "abort trap" for print, abs(2.1)".

  • Marc Schellens
    Marc Schellens

    Please try the CVS version (or just copy math_utl.hpp).
    On my box, the abs definition isn't needed at all

  • Hello,

    G++ 4.5 forbids redeclarations of library functions outside extern "C" blocks
    (fifth item of C++ section in: http://gcc.gnu.org/gcc-4.5/changes.html\).
    I moved the local abs() declaration into the lib namespace - apparently helps. It's in the CVS.

    After the change I was able to compile the CVS version of GDL with GCC 4.5 from Macports
    (before, I reproduced the same error).

    ... anyhow I get the "abort trap" with the GCC 4.5 version even for "print, 2.1" :( :

    The errors seem to be antlr-related? (perhaps time to update the antlr files within GDL?):

    GDL> 1
    terminate called after throwing an instance of 'GDLException'

    Program received signal SIGABRT, Aborted.
    0x941e9e42 in __kill ()
    (gdb) bt
    #0 0x941e9e42 in __kill ()
    #1 0x941e9e34 in kill$UNIX2003 ()
    #2 0x9425c23a in raise ()
    #3 0x94268679 in abort ()
    #4 0x00c89b35 in __gnu_cxx::__verbose_terminate_handler ()
    #5 0x00c874e9 in __cxxabiv1::__terminate ()
    #6 0x00c8754c in std::terminate ()
    #7 0x00c8766b in __cxa_throw ()
    #8 0x00321948 in GDLParser::interactive (this=<value temporarily unavailable, due to optimizations>) at GDLParser.cpp:1589


    • summary: compile error gdl-0.9rc4 with gcc45 --> GCC 4.5 issues (was: compile error gdl-0.9rc4 with gcc45)
  • ... well, I guess that my comment concerning antlr might have been irrelevant - sorry.
    I'm uploading the full backtrace as attachment.


  • In my case it was a Macports-installation-layout problem, this way it works:

    DYLD_LIBRARY_PATH=/opt/local/lib/gcc45 ./gdl


    • status: open --> closed-fixed
  • Marking it as fixed - please resubmit if the problem persists.