Project

General

Profile

Actions

Bug #1459

closed

Code cannot be compiled with default flags in debug mode with gcc-4.8

Added by Alex Afanasyev over 11 years ago. Updated over 11 years ago.

Status:
Closed
Priority:
High
Category:
-
Target version:
-
Start date:
04/10/2014
Due date:
% Done:

100%

Estimated time:

Description

With default debug-mode flags, gcc-4.8 generates the following overflow warnings, preventing code to be compiled:

../src/encoding/tlv.hpp: In function ‘size_t ndn::Tlv::writeVarNumber(std::ostream&, uint64_t)’:
../src/encoding/tlv.hpp:351:15: warning: overflow in implicit constant conversion [-Woverflow]
     os.put(253);
               ^
../src/encoding/tlv.hpp:357:15: warning: overflow in implicit constant conversion [-Woverflow]
     os.put(254);
               ^
../src/encoding/tlv.hpp:363:15: warning: overflow in implicit constant conversion [-Woverflow]
     os.put(255);
               ^
Actions #1

Updated by Alex Afanasyev over 11 years ago

This is not really an overflow, since we are treating each byte as uint8_t. However, specifically in this function we are using standard output stream (std::ostream) interface, which uses char as a base type.

A simple static_cast should make this intention more clear and eliminate the warnings.

Actions #2

Updated by Davide Pesavento over 11 years ago

  • Status changed from Code review to Closed
Actions

Also available in: Atom PDF