<html>
    <head>
      <base href="http://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 --- - No -Wc++-compat warning on uninitialized const field in struct"
   href="http://llvm.org/bugs/show_bug.cgi?id=18923">18923</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>No -Wc++-compat warning on uninitialized const field in struct
          </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>Windows NT
          </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>Frontend
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>chengniansun@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>At trunk 201801. I am not sure whether clang support the warning flag
-Wc++-compat. Currently it does not warn on the uninitialized field in a
struct. 

$: cat s.c 
struct S{const int i;};
void f() {struct S s;}
$: clang-trunk -Wc++-compat -c s.c 
$: clang++ -c s.c
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is
deprecated
s.c:1:8: error: implicit default constructor for 'S' must explicitly initialize
the const member 'i'
struct S{const int i;};
       ^
s.c:1:20: note: declared here
struct S{const int i;};
                   ^
s.c:2:20: note: implicit default constructor for 'S' first required here
void f() {struct S s;}
                   ^
1 error generated.
$: 
$: gcc-trunk -Wc++-compat -c s.c 
s.c: In function ‘f’:
s.c:2:20: warning: uninitialized const member in ‘struct S’ is invalid in C++
[-Wc++-compat]
 void f() {struct S s;}
                    ^
s.c:1:20: note: ‘i’ should be initialized
 struct S{const int i;};
                    ^</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>