Compiling with g++ -std=c++0x, using gcc-4.5.0 :

struct A {
        char x;
};

template<char C> void f() {
        char y = 42;
        A a = { y+C };
}

int main() {
        f<1>();
}

yields an "error: narrowing conversion of ‘(((int)y) + 8)’ from ‘int’
to ‘char’ inside { }".
If I change the template parameter type from "char C" to "int C" the error
message persists, this seems wrong too, but I am not quite shre.

If I leave out the "y", everything is fine.


-- 
           Summary: Bogus narrowing conversion error
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gpiez at web dot de
 GCC build triplet: x86_64-pc-linux-gnu
  GCC host triplet: x86_64-pc-linux-gnu
GCC target triplet: x86_64-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44500

Reply via email to