Opened 7 years ago

Closed 7 years ago

#2009 closed defect (fixed)

const uint8_t {aka const unsigned char}' inside { } is ill-formed in C++11

Reported by: jreed Owned by: muks
Priority: medium Milestone: Sprint-20120612
Component: Unclassified Version:
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: N/A
Sub-Project: DNS Feature Depending on Ticket:
Estimated Difficulty: 4 Add Hours to Ticket: 0
Total Hours: 0 Internal?: no

Description

From http://git.bind10.isc.org/~tester/builder/BIND10-lettuce/20120529132750-DebianLinux-x86_64-GCC/logs/build.out

make[5]: Entering directory `/home/jreed/builder/work/BIND10-lettuce/20120529132750-DebianLinux-x86_64-GCC/build/src/lib/xfr'
/bin/bash ../../../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I../../..  -I../../../src/lib -I../../../src/lib -I../../../src/lib/dns -I../../../src/lib/dns  -DOS_LINUX  -I../../../ext/asio -I../../../ext/coroutine -DASIO_DISABLE_THREADS=1 -Wall -Wextra -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -Werror -fPIC -Wno-unused-parameter  -g -O2 -MT xfrout_client.lo -MD -MP -MF .deps/xfrout_client.Tpo -c -o xfrout_client.lo xfrout_client.cc
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I../../.. -I../../../src/lib -I../../../src/lib -I../../../src/lib/dns -I../../../src/lib/dns -DOS_LINUX -I../../../ext/asio -I../../../ext/coroutine -DASIO_DISABLE_THREADS=1 -Wall -Wextra -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -Werror -fPIC -Wno-unused-parameter -g -O2 -MT xfrout_client.lo -MD -MP -MF .deps/xfrout_client.Tpo -c xfrout_client.cc  -fPIC -DPIC -o .libs/xfrout_client.o
xfrout_client.cc: In member function 'virtual int isc::xfr::XfroutClient::sendXfroutRequestInfo(int, const void*, uint16_t)':
xfrout_client.cc:86:62: error: narrowing conversion of '(((int)msg_len) >> 8)' from 'int' to 'const uint8_t {aka const unsigned char}' inside { } is ill-formed in C++11 [-Werror=narrowing]
xfrout_client.cc:86:62: error: narrowing conversion of '(((int)msg_len) & 255)' from 'int' to 'const uint8_t {aka const unsigned char}' inside { } is ill-formed in C++11 [-Werror=narrowing]
cc1plus: all warnings being treated as errors
make[5]: *** [xfrout_client.lo] Error 1
make[5]: Leaving directory `/home/jreed/builder/work/BIND10-lettuce/20120529132750-DebianLinux-x86_64-GCC/build/src/lib/xfr'

This Debian wheezy/sid box was upgraded. (wheezy is testing and will become next release; sid is unstable and is new packages in development.)

jreed@debian-sid-64-4:~$ ls -l `which g++`
lrwxrwxrwx 1 root root 7 May  7 10:56 /usr/bin/g++ -> g++-4.7
jreed@debian-sid-64-4:~$ g++ --version
g++ (Debian 4.7.0-9) 4.7.0
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Subtickets

Change History (10)

comment:1 Changed 7 years ago by jelte

  • Estimated Difficulty changed from 0 to 4

comment:2 Changed 7 years ago by jreed

make -k doesn't show it anywhere else.

comment:3 Changed 7 years ago by jelte

  • Milestone changed from New Tasks to Sprint-20120612

comment:4 Changed 7 years ago by muks

  • Owner set to muks
  • Status changed from new to assigned

Picking.

(Sorry for picking more than one, but my compiles are taking too long and I can work on this meanwhile.)

comment:5 Changed 7 years ago by muks

  • Owner changed from muks to UnAssigned
  • Status changed from assigned to reviewing

Up for review.

The tree now builds entirely with GCC 4.7.

comment:6 Changed 7 years ago by jinmei

  • Owner changed from UnAssigned to jinmei

comment:7 follow-up: Changed 7 years ago by jinmei

The change (basically) looks okay, but I'm afraid it's not so obvious why we
need to do that, so please add some comments about why. I don't
think I need to check the comment - please add whatever you think
makes sense, and just merge it.

One note: why was 20a21a87777944fea10cf615b0b54d6e96df00ae included in
the branch? It doesn't seem to be related to the topic of this ticket.

Another note: we should kill this stuff anyway and migrate to the
socket session module. And, for that reason, I don't necessarily
think we need a changelog entry for it. But if you think it's worth
mentioning, please do so.

Final note: I've found this:
http://stackoverflow.com/questions/4434140/narrowing-conversions-in-c0x-is-it-just-me-or-does-this-sound-like-a-breakin

comment:8 Changed 7 years ago by jinmei

  • Owner changed from jinmei to muks

comment:9 in reply to: ↑ 7 Changed 7 years ago by muks

Replying to jinmei:

The change (basically) looks okay, but I'm afraid it's not so obvious why we
need to do that, so please add some comments about why. I don't
think I need to check the comment - please add whatever you think
makes sense, and just merge it.

I've added this comment now:

+    // Splitting msg_len below performs something called a 'narrowing
+    // conversion' (conversion of uint16_t to uint8_t). C++0x (and GCC
+    // 4.7) requires explicit casting when a narrowing conversion is
+    // performed. For reference, see 8.5.4/6 of n3225.

One note: why was 20a21a87777944fea10cf615b0b54d6e96df00ae included in
the branch? It doesn't seem to be related to the topic of this ticket.

It isn't related. This is why it's prefixed with [master]. It was 'found' during work on this ticket, so I just checked it into this branch instead of directly in master.

Another note: we should kill this stuff anyway and migrate to the
socket session module. And, for that reason, I don't necessarily
think we need a changelog entry for it. But if you think it's worth
mentioning, please do so.

I'll skip the ChangeLog? entry for this.

Final note: I've found this:
http://stackoverflow.com/questions/4434140/narrowing-conversions-in-c0x-is-it-just-me-or-does-this-sound-like-a-breakin

This was helpful as a reference to write the comment above.

comment:10 Changed 7 years ago by muks

  • Resolution set to fixed
  • Status changed from reviewing to closed

Merged into master:

* afc0fe7 [2009] Add comment about why a static_cast is necessary
* 20a21a8 [master] make sockcreator before sockcreator/tests
* 266ddad [2009] Fix narrowing warnings with GCC 4.7

Resolving as fixed. Thank you for the review.

Note: See TracTickets for help on using tickets.