This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/56292] New: False positive for constexpr arithmetics (-Wconversion)


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: unassigned@gcc.gnu.org
        ReportedBy: lcid-fire@gmx.net


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]