https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109492

            Bug ID: 109492
           Summary: gcc/fortran/trans-expr.cc:3407:17: error: call of
                    overloaded ‘abs(long long int&)’ is ambiguous
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: build
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

Bootstrap fails using gcc-5.5 on Solaris 2.11 (specifically, on gcc211 in the
compile farm):

/export/home/jwakely/src/gcc/gcc/fortran/trans-expr.cc: In function ‘void
gfc_conv_power_op(gfc_se*, gfc_expr*)’:
/export/home/jwakely/src/gcc/gcc/fortran/trans-expr.cc:3407:17: error: call of
overloaded ‘abs(long long int&)’ is ambiguous
       w = abs (v);
                 ^
In file included from /usr/include/stdlib.h:11:0,
                 from /export/home/jwakely/src/gcc/gcc/system.h:266,
                 from
/export/home/jwakely/src/gcc/gcc/fortran/trans-expr.cc:25:
/opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/stdlib_iso.h:163:16:
note: candidate: long int std::abs(long int)
  inline long   abs(long _l) { return labs(_l); }
                ^
/opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/include-fixed/iso/stdlib_iso.h:117:12:
note: candidate: int std::abs(int)
 extern int abs(int);
            ^
gmake[1]: *** [Makefile:1157: fortran/trans-expr.o] Error 1


The problem is that the libc <stdlib.h> is not C++11-aware and so doesn't
provide the long long overload of abs. It is provided by the libstdc++
<cstdlib> header, but only in namespace std.

The solution is to either use std::abs (v) or to do:

--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -3399,6 +3399,7 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr)
   if (INTEGER_CST_P (lse.expr)
       && TREE_CODE (TREE_TYPE (rse.expr)) == INTEGER_TYPE)
     {
+      using std::abs;
       wi::tree_to_wide_ref wlhs = wi::to_wide (lse.expr);
       HOST_WIDE_INT v, w;
       int kind, ikind, bit_size;


The bootstrap compiler is:

Reading specs from /opt/csw/lib/gcc/sparc-sun-solaris2.10/5.5.0/specs
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/csw/libexec/gcc/sparc-sun-solaris2.10/5.5.0/lto-wrapper
Target: sparc-sun-solaris2.10
Configured with:
/home/dam/mgar/pkg/gcc5/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-5.5.0/configure
--prefix=/opt/csw --exec_prefix=/opt/csw --bindir=/opt/csw/bin
--sbindir=/opt/csw/sbin --libexecdir=/opt/csw/libexec --datadir=/opt/csw/share
--sysconfdir=/etc/opt/csw --sharedstatedir=/opt/csw/share
--localstatedir=/var/opt/csw --libdir=/opt/csw/lib
--infodir=/opt/csw/share/info --includedir=/opt/csw/include
--mandir=/opt/csw/share/man --enable-cloog-backend=isl --enable-java-awt=xlib
--enable-languages=ada,c,c++,fortran,go,java,objc --enable-libada
--enable-libssp --enable-nls --enable-objc-gc --enable-threads=posix
--program-suffix=-5.5 --with-cloog=/opt/csw --with-gmp=/opt/csw
--with-included-gettext --with-ld=/usr/ccs/bin/ld --without-gnu-ld
--with-libiconv-prefix=/opt/csw --with-mpfr=/opt/csw --with-ppl=/opt/csw
--with-system-zlib=/opt/csw --with-as=/usr/ccs/bin/as --without-gnu-as
Thread model: posix
gcc version 5.5.0 (GCC) 

This was built on solaris 2.10 so maybe the solution is just to update
/opt/csw/bin/gcc. I'll ask the cfarm admins about that.

Reply via email to