<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - Missed diagnostic in narrowing conversion from unscoped enum to floating"
   href="https://llvm.org/bugs/show_bug.cgi?id=24771">24771</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Missed diagnostic in narrowing conversion from unscoped enum to floating
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++11
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>andrey.vul@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>A narrowing conversion from an unscoped enumeration to a floating-point type
fails to emit a -Wc++11-narrowing diagnostic.

If we try the same, -Wc++11-narrowing works as expected.


### SOURCE:
$ cat narrowing.cc
int x0 = 5;
double y0 = { x0 }; // (1)
enum { z1 = 5 } x1 = z1;
double y1 = { x1 }; // (2)


### COMPILER INVOCATION AND OUTPUT:
$ clang++ -std=c++11 -c -Werror=c++11-narrowing narrowing.cc

narrowing.cc:2:15: error: non-constant-expression cannot be narrowed from type
      'int' to 'double' in initializer list [-Wc++11-narrowing]
double y0 = { x0 };
              ^~
### EXPECTED OUTPUT:
narrowing.cc:2:15: error: non-constant-expression cannot be narrowed from type
      'int' to 'double' in initializer list [-Wc++11-narrowing]
double y0 = { x0 };
              ^~
narrowing.cc:4:15: error: non-constant-expression cannot be narrowed from type
      '<anonymous enum>' to 'double' in initializer list [-Wc++11-narrowing]
double y1 = { x1 };
              ^~

NOTE: the second diagnostic was synthesized from gcc -Werror=narrowing

### COMPILER VERSION INFO:
clang version 3.8.0 (trunk 246556)
Target: powerpc64le-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.8.2
Found candidate GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.9.1
Selected GCC installation: /usr/lib/gcc/powerpc64le-linux-gnu/4.8
Candidate multilib: .;@m64
Selected multilib: .;@m64</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>