http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56292
Bug #: 56292
Summary: False positive for constexpr arithmetics
(-Wconversion)
Classification: Unclassified
Product: gcc
Version: 4.7.2
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
For the following code one gets 'conversion' diagnostics, while the compiler
should be able to compute, that it is actually fine.
#include <cstdint>
constexpr std::uint8_t func() { return 2; }
std::uint8_t value = func() + 2;
Results in:
warning: conversion to ‘uint8_t {aka unsigned char}’ from ‘int’ may alter its
value [-Wconversion]
Diagnostics works fine if you replace 'func()' with a number.