<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 --- - constexpr allows uninitialized variables"
   href="https://llvm.org/bugs/show_bug.cgi?id=25736">25736</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>constexpr allows uninitialized variables
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.7
          </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++14
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Given a code:

    #include <type_traits>

    struct A { int i; };

    template< typename type >
    struct C { constexpr C() = default; type a; };

    struct V { V() = default; C< A > d; };

    constexpr bool test()
    {
        V v;
        static_assert(std::is_trivially_default_constructible< V >::value,
"!");
        return (v.d.a.i == 0);
    }

    static_assert(test(), "!");

It compiles without errors by `clang`. Compilation by `g++` failed with error:

main.cpp: In function 'constexpr bool test()':
main.cpp:12:11: error: uninitialized variable 'v' in 'constexpr' function
         V v;
           ^
main.cpp:8:12: note: 'struct V' has no user-provided default constructor
     struct V { V() = default; C< A > d; };
            ^
main.cpp:8:16: note: constructor is not user-provided because it is explicitly
defaulted in the class body
     struct V { V() = default; C< A > d; };
                ^
main.cpp:3:20: note: and the implicitly-defined constructor does not initialize
'int A::i'
     struct A { int i; };
                    ^
main.cpp: At global scope:
main.cpp:17:5: error: non-constant condition for static assertion
     static_assert(test(), "!");
     ^
main.cpp:17:23: error: 'constexpr bool test()' called in a constant expression
     static_assert(test(), "!");
                       ^

If I remove `template`s and substitute `A` directly, then `clang` sees
uninitialized during default construction variables.
If I remove `constexpr` specifier of `C::C()` default constructor, then `clang`
also sees wrong things.</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>