<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - clang-6: __has_cpp_attribute(nodiscard) == true with -std=c++14, but warns about usage with -pedantic"
   href="https://bugs.llvm.org/show_bug.cgi?id=43743">43743</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang-6: __has_cpp_attribute(nodiscard) == true with -std=c++14, but warns about usage with -pedantic
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>6.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </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++14
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>hans.dembinski@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>__has_cpp_attribute(nodiscard) wrongly returns true when `-std=c++14` is
selected. The expected behavior is to return false in this case.

This is a problem for libraries which conditionally use [[nodiscard]] when it
is available but also want to compile cleanly with -pedantic -Werror. This is
the case for some Boost libraries. clang-6 errors with `-std=c++14 -pedantic
-Werror` when [[nodiscard]] is used - although its detection macro indicates
its availability. This is inconsistent.

Demo on Godbolt:
<a href="https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(j:1,lang:c%2B%2B,source:'int+main()+%7B%0A++++//+nodiscard+is+C%2B%2B17,+but+accepted+with+-std%3Dc%2B%2B14%0A++++static_assert(__has_cpp_attribute(nodiscard),+%22%22)%3B%0A++++struct+%5B%5Bnodiscard%5D%5D+foo+%7B%7D%3B%0A%7D%0A'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:clang600,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'1',trim:'1'),lang:c%2B%2B,libs:!((name:boost,ver:'171')),options:'-std%3Dc%2B%2B14+-pedantic+-Werror',source:1),l:'5',n:'0',o:'x86-64+clang+6.0.0+(Editor+%231,+Compiler+%231)+C%2B%2B',t:'0')),k:50,l:'4',m:71.99297629499561,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compiler:1,editor:1,wrap:'1'),l:'5',n:'0',o:'%231+with+x86-64+clang+6.0.0',t:'0')),header:(),l:'4',m:28.007023705004386,n:'0',o:'',s:0,t:'0')),k:50,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4">https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(j:1,lang:c%2B%2B,source:'int+main()+%7B%0A++++//+nodiscard+is+C%2B%2B17,+but+accepted+with+-std%3Dc%2B%2B14%0A++++static_assert(__has_cpp_attribute(nodiscard),+%22%22)%3B%0A++++struct+%5B%5Bnodiscard%5D%5D+foo+%7B%7D%3B%0A%7D%0A'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:50,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((g:!((h:compiler,i:(compiler:clang600,filters:(b:'0',binary:'1',commentOnly:'0',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'1',trim:'1'),lang:c%2B%2B,libs:!((name:boost,ver:'171')),options:'-std%3Dc%2B%2B14+-pedantic+-Werror',source:1),l:'5',n:'0',o:'x86-64+clang+6.0.0+(Editor+%231,+Compiler+%231)+C%2B%2B',t:'0')),k:50,l:'4',m:71.99297629499561,n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compiler:1,editor:1,wrap:'1'),l:'5',n:'0',o:'%231+with+x86-64+clang+6.0.0',t:'0')),header:(),l:'4',m:28.007023705004386,n:'0',o:'',s:0,t:'0')),k:50,l:'3',n:'0',o:'',t:'0')),l:'2',n:'0',o:'',t:'0')),version:4</a></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>