Discussion:
[Bug build/23087] New: Stop relying on -Wno-narrowing
palves at redhat dot com
2018-04-19 15:50:14 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23087

Bug ID: 23087
Summary: Stop relying on -Wno-narrowing
Product: gdb
Version: HEAD
Status: NEW
Severity: normal
Priority: P2
Component: build
Assignee: unassigned at sourceware dot org
Reporter: palves at redhat dot com
Target Milestone: ---

Early in gdb's C++ conversion, at
<https://sourceware.org/ml/gdb-patches/2015-02/msg00203.html>, we added
-Wno-narrowing to the build flags with the following comment:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
. Adding -Wno-narrowing suppresses thousands of instances of this warning:

gdb/arm-linux-tdep.c:439:1: error: narrowing conversion of â-1â from int to
âULONGEST {aka long unsigned int} inside { } is ill-formed in C++11
[-Werror=narrowing]
gdb/arm-linux-tdep.c:439:1: error: narrowing conversion of -1 from LONGEST
{aka long int} to ULONGEST {aka long unsigned int} inside { } is ill-formed in
C++11 [-Werror=narrowing]
gdb/arm-linux-tdep.c:450:1: error: narrowing conversion of -1 from int to
ULONGEST {aka long unsigned int} inside { } is ill-formed in C++11
[-Werror=narrowing]

We can defer handling those until we target C++11.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Not that long after however, we started requiring C++11, but the warning/error
suppression is still in place, as the reason for having it.

I don't think any compiler is going to miscompile such code, though ideally
we'd fix it for good, since the narrowing conversions are ill-formed C++11.

We could fix that with e.g., explicit casting at each call site:

CORE_ADDR breaks[2] = { (CORE_ADDR) -1, (CORE_ADDR) -1 };

Or perhaps better add a CORE_ADDR_MAX and use it throughout:

#define CORE_ADDR_MAX ((CORE_ADDR) -1)

CORE_ADDR breaks[2] = { CORE_ADDR_MAX, CORE_ADDR_MAX };
--
You are receiving this mail because:
You are on the CC list for the bug.
palves at redhat dot com
2018-04-19 15:51:35 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23087

Pedro Alves <palves at redhat dot com> changed:

What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://sourceware.org/bugz
| |illa/show_bug.cgi?id=22098
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-08-07 12:50:27 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23087

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |alfedotov at gmail dot com

--- Comment #1 from Tom Tromey <tromey at sourceware dot org> ---
*** Bug 22098 has been marked as a duplicate of this bug. ***
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-08-07 19:13:48 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23087

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |tromey at sourceware dot org
Assignee|unassigned at sourceware dot org |tromey at sourceware dot org

--- Comment #2 from Tom Tromey <tromey at sourceware dot org> ---
I've got a patch that works for my build.
Haven't tried the buildbot yet.
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2018-08-27 18:10:30 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23087

--- Comment #3 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Tom Tromey <***@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d3d8724aac2f207467b1004b1424fed0446b6f8a

commit d3d8724aac2f207467b1004b1424fed0446b6f8a
Author: Tom Tromey <***@tromey.com>
Date: Tue Aug 7 13:14:09 2018 -0600

Remove -Wno-narrowing from warnings.m4

This removes -Wno-narrowing from warnings.m4.
This is PR build/23087.

gdb/ChangeLog
2018-08-27 Tom Tromey <***@tromey.com>

PR build/23087:
* configure: Rebuild.
* warning.m4 (AM_GDB_WARNINGS): Remove -Wno-narrowing.

gdb/gdbserver/ChangeLog
2018-08-27 Tom Tromey <***@tromey.com>

PR build/23087:
* configure: Rebuild.
--
You are receiving this mail because:
You are on the CC list for the bug.
tromey at sourceware dot org
2018-08-27 18:11:09 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23087

Tom Tromey <tromey at sourceware dot org> changed:

What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |8.3

--- Comment #4 from Tom Tromey <tromey at sourceware dot org> ---
Fixed.
--
You are receiving this mail because:
You are on the CC list for the bug.
cvs-commit at gcc dot gnu.org
2018-09-18 07:17:02 UTC
Permalink
https://sourceware.org/bugzilla/show_bug.cgi?id=23087

--- Comment #5 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Rainer Orth <***@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=206c1947c1cb8e4ac6abb8e6803c762200167cde

commit 206c1947c1cb8e4ac6abb8e6803c762200167cde
Author: Rainer Orth <***@CeBiTec.Uni-Bielefeld.DE>
Date: Tue Sep 18 09:14:11 2018 +0200

Cast RLIM_INFINITY to rlim_t to fix 64-bit Solaris 10 build

gdb doesn't currently build on 64-bit Solaris 10:

/vol/src/gnu/gdb/hg/master/local/gdb/utils.c: In function ‘void
dump_core()’:
/vol/src/gnu/gdb/hg/master/local/gdb/utils.c:223:55: error: narrowing
conversion
of ‘-3’ from ‘long int’ to ‘rlim_t’ {aka ‘long unsigned int’} inside {
} [-Wnarrowing]
struct rlimit rlim = { RLIM_INFINITY, RLIM_INFINITY };
^
/vol/src/gnu/gdb/hg/master/local/gdb/utils.c:223:55: error: narrowing
conversion
of ‘-3’ from ‘long int’ to ‘rlim_t’ {aka ‘long unsigned int’} inside {
} [-Wnarrowing]

This was introduced by

2018-08-27 Tom Tromey <***@tromey.com>

PR build/23087:
* configure: Rebuild.
* warning.m4 (AM_GDB_WARNINGS): Remove -Wno-narrowing.

and can be fixed by the following patch.

Solaris 11 isn't affected because there <sys/resource.h> has

#define RLIM_INFINITY ((rlim_t)-3l)

instead of

#define RLIM_INFINITY (-3l)

on Solaris 10.

Tested on amd64-pc-solaris2.10 and amd64-pc-solaris2.11.

* utils.c (dump_core) [HAVE_SETRLIMIT]: Cast RLIM_INFINITY to
rlim_t.
--
You are receiving this mail because:
You are on the CC list for the bug.
Loading...