<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 --- - C++1y "void is a literal type" should be accepted in C++11 mode with a warning"
   href="http://llvm.org/bugs/show_bug.cgi?id=19714">19714</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>C++1y "void is a literal type" should be accepted in C++11 mode with a warning
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>3.4
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </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>arthur.j.odwyer@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>cat >test.cc <<EOF
#include <stdio.h>
template<typename T> void print_if_not_int(T t) { puts("hi"); }
template<> constexpr void print_if_not_int<int>(int) { }
int main() { print_if_not_int(1); }
EOF

clang++ -std=c++11 test.cc

    test.cc:3:27: error: constexpr function's return type 'void' is not a
literal type
    template<> constexpr void print_if_not_int<int>(int) { }
                              ^
    test.cc:4:14: error: no matching function for call to 'print_if_not_int'
    int main() { print_if_not_int(1); }
                 ^~~~~~~~~~~~~~~~
    test.cc:2:27: note: candidate template ignored: substitution failure [with
T = int]
    template<typename T> void print_if_not_int(T t) { puts("hi"); }
                              ^
    2 errors generated.

Apparently Standard C++11 requires the programmer to remember to type "inline"
instead of "constexpr" in cases where the function's return type is "void".
However, GNU GCC doesn't require any such thing, which means that there are
GCC-compatible programs floating around out there which don't build (and give
weird, unsuppressible substitution-failure errors) with Clang.

C++14 permits "constexpr" to be used with a "void" function.
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3444.html">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3444.html</a>

Clang should allow the programmer to use this GCC and/or C++14 feature in their
C++11 programs, if possible. Introducing a new diagnostic something like
-Wvoid-literal-type (warning by default in C++11 mode) would enable the
programmer to use this feature without necessarily pulling in all of C++14.

I don't know whether there's any Standard justification for simply *allowing*
void as a literal type in C++11 mode. I know in some cases the resolutions of
DRs are "back-ported" into older standards if it's determined that they fix
"bugs" in the older standards. I don't know if this particular issue qualifies
for that kind of treatment.</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>