[LLVMbugs] [Bug 18923] New: No -Wc++-compat warning on uninitialized const field in struct

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Feb 20 21:28:12 PST 2014


http://llvm.org/bugs/show_bug.cgi?id=18923

            Bug ID: 18923
           Summary: No -Wc++-compat warning on uninitialized const field
                    in struct
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: chengniansun at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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;};
                    ^

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140221/25fe0820/attachment.html>


More information about the llvm-bugs mailing list