public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
@ 2020-03-26 16:12 alexey.brodkin at gmail dot com
2020-03-26 16:13 ` [Bug build/25731] " alexey.brodkin at gmail dot com
` (15 more replies)
0 siblings, 16 replies; 17+ messages in thread
From: alexey.brodkin at gmail dot com @ 2020-03-26 16:12 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
Bug ID: 25731
Summary: Build failure on Darwin/macOS: error: no member named
'abs' in namespace 'std'
Product: gdb
Version: HEAD
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: build
Assignee: unassigned at sourceware dot org
Reporter: alexey.brodkin at gmail dot com
CC: andrew.burgess at embecosm dot com, shahab.vahedi at gmail dot com
Target Milestone: ---
Host: Darwin
On current HEAD compilation fails in Darwin/macOS this way:
--------------------------------->8--------------------------------
$ ../binutils-gdb/configure --disable-binutils --disable-ld --disable-gold
--disable-gas --disable-sim --disable-gprof --disable-werror
$ make
CXX gdbtypes.o
In file included from ../../binutils-gdb/gdb/gdbtypes.c:22:
In file included from ../../binutils-gdb/gdb/defs.h:630:
In file included from ../../binutils-gdb/gdb/utils.h:24:
In file included from ../../binutils-gdb/gdb/exceptions.h:23:
../../binutils-gdb/gdb/ui-out.h:113:11: warning: returning address of local
temporary object [-Wreturn-stack-address]
return &tmp;
^~~
../../binutils-gdb/gdb/ui-out.h:108:25: note: binding reference variable 'tmp'
here
signed_field_s &&tmp = {})
^ ~~~~
../../binutils-gdb/gdb/ui-out.h:134:11: warning: returning address of local
temporary object [-Wreturn-stack-address]
return &tmp;
^~~
../../binutils-gdb/gdb/ui-out.h:129:25: note: binding reference variable 'tmp'
here
string_field_s &&tmp = {})
^ ~~~~
../../binutils-gdb/gdb/ui-out.h:158:11: warning: returning address of local
temporary object [-Wreturn-stack-address]
return &tmp;
^~~
../../binutils-gdb/gdb/ui-out.h:154:27: note: binding reference variable 'tmp'
here
styled_string_s &&tmp = {})
^ ~~
../../binutils-gdb/gdb/gdbtypes.c:1252:28: error: no member named 'abs' in
namespace 'std'; did you mean simply 'abs'?
LONGEST element_count = std::abs (high_bound - low_bound + 1);
^~~~~~~~
abs
/usr/include/stdlib.h:129:6: note: 'abs' declared here
int abs(int) __pure2;
^
../../binutils-gdb/gdb/gdbtypes.c:1254:10: error: no member named 'abs' in
namespace 'std'; did you mean simply 'abs'?
= ((std::abs (stride) * element_count) + 7) / 8;
^~~~~~~~
abs
/usr/include/stdlib.h:129:6: note: 'abs' declared here
int abs(int) __pure2;
^
3 warnings and 2 errors generated.
make[2]: *** [gdbtypes.o] Error 1
make[1]: *** [all-gdb] Error 2
make: *** [all] Error 2
--------------------------------->8--------------------------------
I guess it started to happen after commit 3104d9ee2231 ("gdb: Use std::abs
instead of abs on LONGEST types"), see
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=3104d9ee223133b9f5be4ec96b3f986e4fbc893e
The following fixes that failure:
--------------------------------->8--------------------------------
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index d89df9f7409..a6ef14c2e4c 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -40,6 +40,8 @@
#include "gdbcore.h"
#include "floatformat.h"
+#include <cstdlib>
+
/* Initialize BADNESS constants. */
const struct rank LENGTH_MISMATCH_BADNESS = {100,0};
--------------------------------->8--------------------------------
FWIW:
--------------------------------->8--------------------------------
$ gcc -v
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
--------------------------------->8--------------------------------
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
@ 2020-03-26 16:13 ` alexey.brodkin at gmail dot com
2020-03-26 16:25 ` simark at simark dot ca
` (14 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: alexey.brodkin at gmail dot com @ 2020-03-26 16:13 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
Alexey Brodkin <alexey.brodkin at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |alexey.brodkin at gmail dot com
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
2020-03-26 16:13 ` [Bug build/25731] " alexey.brodkin at gmail dot com
@ 2020-03-26 16:25 ` simark at simark dot ca
2020-03-26 16:57 ` simark at simark dot ca
` (13 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: simark at simark dot ca @ 2020-03-26 16:25 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
Simon Marchi <simark at simark dot ca> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |simark at simark dot ca
--- Comment #1 from Simon Marchi <simark at simark dot ca> ---
Thanks for reporting. I'll push a patch directly, since this is obvious, but
next time don't hesitate to send your patch to the gdb-patches mailing list, as
described here:
https://sourceware.org/gdb/wiki/ContributionChecklist
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
2020-03-26 16:13 ` [Bug build/25731] " alexey.brodkin at gmail dot com
2020-03-26 16:25 ` simark at simark dot ca
@ 2020-03-26 16:57 ` simark at simark dot ca
2020-03-26 16:58 ` simark at simark dot ca
` (12 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: simark at simark dot ca @ 2020-03-26 16:57 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
--- Comment #2 from Simon Marchi <simark at simark dot ca> ---
Hmm, in fact I can't reproduce locally. Here's how this file is built for me:
$ gdb gnumake gdbtypes.o V=1
g++ -x c++ -std=gnu++11 -g3 -O0 -I. -I../../binutils-gdb/gdb
-I../../binutils-gdb/gdb/config -DLOCALEDIR="\"/usr/local/share/locale\""
-DHAVE_CONFIG_H -I../../binutils-gdb/gdb/../include/opcode
-I../../binutils-gdb/gdb/../readline/readline/..
-I../../binutils-gdb/gdb/../zlib -I../bfd -I../../binutils-gdb/gdb/../bfd
-I../../binutils-gdb/gdb/../include -I../libdecnumber
-I../../binutils-gdb/gdb/../libdecnumber -I./../intl
-I../../binutils-gdb/gdb/../gnulib/import -I../gnulib/import
-I../../binutils-gdb/gdb/.. -I.. -DTUI=1
-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
-I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7
-I../../binutils-gdb/gdb/.. -pthread -Wall -Wpointer-arith -Wno-unused
-Wunused-value -Wunused-function -Wno-switch -Wno-char-subscripts -Wempty-body
-Wno-sign-compare -Wno-mismatched-tags -Wno-error=deprecated-register
-Wredundant-move -Wmissing-declarations -Wmissing-prototypes -Wformat
-Wformat-nonliteral -Werror -c -o gdbtypes.o -MT gdbtypes.o -MMD -MP -MF
./.deps/gdbtypes.Tpo ../../binutils-gdb/gdb/gdbtypes.c
$ gdb which g++
/usr/bin/g++
$ gdb g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Do you have any idea why I don't see the same failure as you?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
` (2 preceding siblings ...)
2020-03-26 16:57 ` simark at simark dot ca
@ 2020-03-26 16:58 ` simark at simark dot ca
2020-03-26 17:39 ` simark at simark dot ca
` (11 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: simark at simark dot ca @ 2020-03-26 16:58 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
--- Comment #3 from Simon Marchi <simark at simark dot ca> ---
(In reply to Simon Marchi from comment #2)
> Hmm, in fact I can't reproduce locally. Here's how this file is built for
> me:
>
> $ gdb gnumake gdbtypes.o V=1
> ...
> $ gdb which g++
> ...
> $ gdb g++ --version
Err, ignore the leading "gdb" in those commands, that was part of my prompt.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
` (3 preceding siblings ...)
2020-03-26 16:58 ` simark at simark dot ca
@ 2020-03-26 17:39 ` simark at simark dot ca
2020-03-27 8:05 ` alexey.brodkin at gmail dot com
` (10 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: simark at simark dot ca @ 2020-03-26 17:39 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
--- Comment #4 from Simon Marchi <simark at simark dot ca> ---
I noticed that we already include stdlib.h in common-defs.h:
https://sourceware.org/git/?p=binutils-gdb.git;a=blob;f=gdbsupport/common-defs.h;h=e42d2b80c045361cfa19f52cb146ae32c58f61b3;hb=HEAD#l87
However, according to [1], C++ standard library implementations are not
mandated to make stdlib.h populate the std namespace. I guess your C++ library
doesn't.
[1] https://en.cppreference.com/w/cpp/header
So since we use std::abs, the correct thing to do would indeed be to include
cstdlib. I tried to swap stdlib.h for cstdlib in common-defs.h, I just
stumbled on some old hack in ada-exp.y that can probably be removed. But
otherwise it builds for me.
Can you see if the patch below builds fine for you on macOS?
>From 8ca602f1a6b05cb431b663c8ed0c09537fe31960 Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@efficios.com>
Date: Thu, 26 Mar 2020 13:27:07 -0400
Subject: [PATCH] allo
---
gdb/ada-exp.y | 3 ---
gdbsupport/common-defs.h | 2 +-
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index c5e1e14299e..6e65b212e24 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -720,9 +720,6 @@ primary : '*' primary %prec '.'
static struct obstack temp_parse_space;
-/* The following kludge was found necessary to prevent conflicts between */
-/* defs.h and non-standard stdlib.h files. */
-#define qsort __qsort__dummy
#include "ada-lex.c"
int
diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h
index e42d2b80c04..e1a431c6939 100644
--- a/gdbsupport/common-defs.h
+++ b/gdbsupport/common-defs.h
@@ -84,7 +84,7 @@
#include <stdarg.h>
#include <stdio.h>
-#include <stdlib.h>
+#include <cstdlib>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
--
2.25.1
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
` (4 preceding siblings ...)
2020-03-26 17:39 ` simark at simark dot ca
@ 2020-03-27 8:05 ` alexey.brodkin at gmail dot com
2020-04-01 22:56 ` alexey.brodkin at gmail dot com
` (9 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: alexey.brodkin at gmail dot com @ 2020-03-27 8:05 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
--- Comment #5 from Alexey Brodkin <alexey.brodkin at gmail dot com> ---
Indeed with proposed patch it builds perfectly fine.
Though I don't have an answer to your question why the same problem is not
reproduced on your side, sorry.
And thanks a lot for the prompt fix!
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
` (5 preceding siblings ...)
2020-03-27 8:05 ` alexey.brodkin at gmail dot com
@ 2020-04-01 22:56 ` alexey.brodkin at gmail dot com
2020-04-03 20:05 ` tromey at sourceware dot org
` (8 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: alexey.brodkin at gmail dot com @ 2020-04-01 22:56 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
--- Comment #6 from Alexey Brodkin <alexey.brodkin at gmail dot com> ---
Hi Simon,
Do you still have any doubts about your fix from comment #4?
Otherwise it would be good to get it merged so it won't slip through the
cracks.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
` (6 preceding siblings ...)
2020-04-01 22:56 ` alexey.brodkin at gmail dot com
@ 2020-04-03 20:05 ` tromey at sourceware dot org
2020-04-09 21:32 ` alexey.brodkin at gmail dot com
` (7 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: tromey at sourceware dot org @ 2020-04-03 20:05 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
--- Comment #7 from Tom Tromey <tromey at sourceware dot org> ---
FWIW it looks fine to me.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
` (7 preceding siblings ...)
2020-04-03 20:05 ` tromey at sourceware dot org
@ 2020-04-09 21:32 ` alexey.brodkin at gmail dot com
2020-04-09 21:52 ` simark at simark dot ca
` (6 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: alexey.brodkin at gmail dot com @ 2020-04-09 21:32 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
--- Comment #8 from Alexey Brodkin <alexey.brodkin at gmail dot com> ---
Sorry for bugging you but is there a chance to get proposed fix committed
sometime soon?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
` (8 preceding siblings ...)
2020-04-09 21:32 ` alexey.brodkin at gmail dot com
@ 2020-04-09 21:52 ` simark at simark dot ca
2020-04-09 22:51 ` simark at simark dot ca
` (5 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: simark at simark dot ca @ 2020-04-09 21:52 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
--- Comment #9 from Simon Marchi <simark at simark dot ca> ---
I'll send something on the list.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
` (9 preceding siblings ...)
2020-04-09 21:52 ` simark at simark dot ca
@ 2020-04-09 22:51 ` simark at simark dot ca
2020-04-27 12:52 ` alexey.brodkin at gmail dot com
` (4 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: simark at simark dot ca @ 2020-04-09 22:51 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
Simon Marchi <simark at simark dot ca> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2020-04-09
Ever confirmed|0 |1
--- Comment #10 from Simon Marchi <simark at simark dot ca> ---
Patch posted here:
https://sourceware.org/pipermail/gdb-patches/2020-April/167501.html
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
` (10 preceding siblings ...)
2020-04-09 22:51 ` simark at simark dot ca
@ 2020-04-27 12:52 ` alexey.brodkin at gmail dot com
2020-04-27 13:21 ` simark at simark dot ca
` (3 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: alexey.brodkin at gmail dot com @ 2020-04-27 12:52 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
Alexey Brodkin <alexey.brodkin at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |cbiesinger at google dot com
--- Comment #11 from Alexey Brodkin <alexey.brodkin at gmail dot com> ---
Yet another gentle reminder :)
There seems to be a discussion on the mailing list which stops here:
https://sourceware.org/pipermail/gdb-patches/2020-April/167520.html
Do we need a re-spin or it might be fixed-up by the committer?
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
` (11 preceding siblings ...)
2020-04-27 12:52 ` alexey.brodkin at gmail dot com
@ 2020-04-27 13:21 ` simark at simark dot ca
2020-04-27 13:28 ` cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
15 siblings, 0 replies; 17+ messages in thread
From: simark at simark dot ca @ 2020-04-27 13:21 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
--- Comment #12 from Simon Marchi <simark at simark dot ca> ---
Thanks for the reminder, I'm not very good at tracking my own patches... I'll
push it, as nobody opposed, we'll see if it breaks something somewhere.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
` (12 preceding siblings ...)
2020-04-27 13:21 ` simark at simark dot ca
@ 2020-04-27 13:28 ` cvs-commit at gcc dot gnu.org
2020-04-27 13:28 ` simark at simark dot ca
2020-04-27 13:29 ` tromey at sourceware dot org
15 siblings, 0 replies; 17+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-27 13:28 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
--- Comment #13 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Simon Marchi <simark@sourceware.org>:
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ff8885c3be6f42ed90a7b0ec0028fad26861cd94
commit ff8885c3be6f42ed90a7b0ec0028fad26861cd94
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date: Mon Apr 27 09:19:48 2020 -0400
gdbsupport: include cstdlib in common-defs.h
In PR 25731 [1], the following build failure was reported:
../../binutils-gdb/gdb/gdbtypes.c:1254:10: error: no member named 'abs'
in namespace 'std'; did you mean simply 'abs'?
= ((std::abs (stride) * element_count) + 7) / 8;
^~~~~~~~
abs
/usr/include/stdlib.h:129:6: note: 'abs' declared here
int abs(int) __pure2;
^
The original report was using:
$ gcc -v
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Note that I was _not_ able to reproduce using:
$ g++ --version
Configured with:
--prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.3.0
The proposed fix is to include <cstdlib> in addition to <stdlib.h>.
Here's an excerpt of [2] relevant to this problem:
These headers [speaking of the .h form] are allowed to also declare
the same names in the std namespace, and the corresponding cxxx
headers are allowed to also declare the same names in the global
namespace: including <cstdlib> definitely provides std::malloc and
may also provide ::malloc. Including <stdlib.h> definitely provides
::malloc and may also provide std::malloc
Since we use std::abs, we should not assume that our include of stdlib.h
declares an `abs` function in the `std` namespace.
If we replace the include of stdlib.h with cstdlib, then we fall in the
opposite situation. A standard C++ library may decide to only put the
declarations in the std namespace, requiring us to prefix all standard
functions with `std::`. I'm not against that, but for the moment I think
the
safest way forward is to just include both.
Note that I don't know what effect this patch can have on any stdlib.h fix
provided by gnulib.
[1] https://sourceware.org/bugzilla/show_bug.cgi?id=25731
[2] https://en.cppreference.com/w/cpp/header#C_compatibility_headers
gdbsupport/ChangeLog:
* common-defs.h: Include cstdlib.h.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
` (13 preceding siblings ...)
2020-04-27 13:28 ` cvs-commit at gcc dot gnu.org
@ 2020-04-27 13:28 ` simark at simark dot ca
2020-04-27 13:29 ` tromey at sourceware dot org
15 siblings, 0 replies; 17+ messages in thread
From: simark at simark dot ca @ 2020-04-27 13:28 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
Simon Marchi <simark at simark dot ca> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #14 from Simon Marchi <simark at simark dot ca> ---
Fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
* [Bug build/25731] Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std'
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
` (14 preceding siblings ...)
2020-04-27 13:28 ` simark at simark dot ca
@ 2020-04-27 13:29 ` tromey at sourceware dot org
15 siblings, 0 replies; 17+ messages in thread
From: tromey at sourceware dot org @ 2020-04-27 13:29 UTC (permalink / raw)
To: gdb-prs
https://sourceware.org/bugzilla/show_bug.cgi?id=25731
Tom Tromey <tromey at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.1
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2020-04-27 13:29 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 16:12 [Bug build/25731] New: Build failure on Darwin/macOS: error: no member named 'abs' in namespace 'std' alexey.brodkin at gmail dot com
2020-03-26 16:13 ` [Bug build/25731] " alexey.brodkin at gmail dot com
2020-03-26 16:25 ` simark at simark dot ca
2020-03-26 16:57 ` simark at simark dot ca
2020-03-26 16:58 ` simark at simark dot ca
2020-03-26 17:39 ` simark at simark dot ca
2020-03-27 8:05 ` alexey.brodkin at gmail dot com
2020-04-01 22:56 ` alexey.brodkin at gmail dot com
2020-04-03 20:05 ` tromey at sourceware dot org
2020-04-09 21:32 ` alexey.brodkin at gmail dot com
2020-04-09 21:52 ` simark at simark dot ca
2020-04-09 22:51 ` simark at simark dot ca
2020-04-27 12:52 ` alexey.brodkin at gmail dot com
2020-04-27 13:21 ` simark at simark dot ca
2020-04-27 13:28 ` cvs-commit at gcc dot gnu.org
2020-04-27 13:28 ` simark at simark dot ca
2020-04-27 13:29 ` tromey at sourceware dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).