aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2005-05-26 15:46:48 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2005-05-26 15:46:48 +0000
commit10d877a8ed148010bab7bb8d669c6e21665a531a (patch)
tree7a5f4909b67f08a378aa148f04d96411c09a0e3a
parent2fe96b0a8394a7d42135ce9172a5a074127e9c61 (diff)
downloadgcc-10d877a8ed148010bab7bb8d669c6e21665a531a.zip
gcc-10d877a8ed148010bab7bb8d669c6e21665a531a.tar.gz
gcc-10d877a8ed148010bab7bb8d669c6e21665a531a.tar.bz2
re PR libstdc++/13943 (call of overloaded `llabs(int)' is ambiguous)
2005-05-26 Paolo Carlini <pcarlini@suse.de> PR libstdc++/13943 * include/c_std/std_cstdlib.h: Do not open code llabs and lldiv, available when _GLIBCXX_USE_C99 is defined. * testsuite/26_numerics/cstdlib/13943.cc: New. * acinclude.m4 ([GLIBCXX_ENABLE_C99]): For completeness, check also strtoll and strtoull for ac_c99_stdlib. * configure: Regenerate. From-SVN: r100205
-rw-r--r--libstdc++-v3/ChangeLog11
-rw-r--r--libstdc++-v3/acinclude.m412
-rwxr-xr-xlibstdc++-v3/configure4
-rw-r--r--libstdc++-v3/include/c_std/std_cstdlib.h13
-rw-r--r--libstdc++-v3/testsuite/26_numerics/cstdlib/13943.cc52
5 files changed, 78 insertions, 14 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index e1995d5..6314115 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,14 @@
+2005-05-26 Paolo Carlini <pcarlini@suse.de>
+
+ PR libstdc++/13943
+ * include/c_std/std_cstdlib.h: Do not open code llabs and lldiv,
+ available when _GLIBCXX_USE_C99 is defined.
+ * testsuite/26_numerics/cstdlib/13943.cc: New.
+
+ * acinclude.m4 ([GLIBCXX_ENABLE_C99]): For completeness, check
+ also strtoll and strtoull for ac_c99_stdlib.
+ * configure: Regenerate.
+
2005-05-25 Benjamin Kosnik <bkoz@redhat.com>
* config/linker-map.gnu: Add linkage support for no extern templates.
diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 757a0e8..86a52e5 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -879,12 +879,14 @@ AC_DEFUN([GLIBCXX_ENABLE_C99], [
AC_MSG_CHECKING([for ISO C99 support in <stdlib.h>])
AC_CACHE_VAL(ac_c99_stdlib, [
AC_TRY_COMPILE([#include <stdlib.h>],
- [char* tmp;
- strtof("gnu", &tmp);
+ [char* tmp;
+ strtof("gnu", &tmp);
strtold("gnu", &tmp);
- llabs(10);
- lldiv(10,1);
- atoll("10");
+ strtoll("gnu", &tmp, 10);
+ strtoull("gnu", &tmp, 10);
+ llabs(10);
+ lldiv(10,1);
+ atoll("10");
_Exit(0);
lldiv_t mydivt;],[ac_c99_stdlib=yes], [ac_c99_stdlib=no])
])
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 9b4cc23..9e0d61d 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -7059,7 +7059,9 @@ main ()
char* tmp;
strtof("gnu", &tmp);
strtold("gnu", &tmp);
- llabs(10);
+ strtoll("gnu", &tmp, 10);
+ strtoull("gnu", &tmp, 10);
+ llabs(10);
lldiv(10,1);
atoll("10");
_Exit(0);
diff --git a/libstdc++-v3/include/c_std/std_cstdlib.h b/libstdc++-v3/include/c_std/std_cstdlib.h
index 3fde655..cf91f27 100644
--- a/libstdc++-v3/include/c_std/std_cstdlib.h
+++ b/libstdc++-v3/include/c_std/std_cstdlib.h
@@ -1,6 +1,6 @@
// -*- C++ -*- forwarding header.
-// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
+// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -168,17 +168,14 @@ namespace __gnu_cxx
inline long long
abs(long long __x) { return __x >= 0 ? __x : -__x; }
- inline long long
- llabs(long long __x) { return __x >= 0 ? __x : -__x; }
-
#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
+ using ::llabs;
+
inline lldiv_t
div(long long __n, long long __d)
{ lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
- inline lldiv_t
- lldiv(long long __n, long long __d)
- { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
+ using ::lldiv;
#endif
#if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
@@ -204,8 +201,8 @@ namespace std
#endif
using __gnu_cxx::_Exit;
using __gnu_cxx::abs;
- using __gnu_cxx::llabs;
#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
+ using __gnu_cxx::llabs;
using __gnu_cxx::div;
using __gnu_cxx::lldiv;
#endif
diff --git a/libstdc++-v3/testsuite/26_numerics/cstdlib/13943.cc b/libstdc++-v3/testsuite/26_numerics/cstdlib/13943.cc
new file mode 100644
index 0000000..920ddcc
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/cstdlib/13943.cc
@@ -0,0 +1,52 @@
+// Copyright (C) 2005 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+#include <cstdlib>
+#include <testsuite_hooks.h>
+
+#if _GLIBCXX_USE_C99
+// libstdc++/13943
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ VERIFY( llabs(-3) == 3 );
+
+ lldiv_t q = lldiv(6, 4);
+ VERIFY( q.quot == 1 );
+ VERIFY( q.rem == 2 );
+}
+#endif
+
+int main()
+{
+#if _GLIBCXX_USE_C99
+ test01();
+#endif
+ return 0;
+}