<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 --- - Noisy warnings about const-attributed functions used in decltype"
   href="http://llvm.org/bugs/show_bug.cgi?id=18571">18571</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Noisy warnings about const-attributed functions used in decltype
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>trunk
          </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>akim.demaille@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>It is very handy to use "decltype" to perform a snifae dispatch, as in this
example:

__attribute__((const))
bool bar()
{
  return true;
}

template <typename T>
auto foo(T t) -> decltype(bar(), bool())
{
  return true;
}

template <typename T>
bool foo(...)
{
  return false;
}

int main()
{
  return foo(23) != true;
}

Unfortunately, clang complains that the function I'm sfinaeing on, bar, is
const, and its result is ignored.  The warning in itself makes sense, but not
here.  In addition, it stutters.

akim@erebus /tmp $ clang++-mp-3.4 -std=c++11 sfinae.cc -Wall
sfinae.cc:8:27: warning: ignoring return value of function declared with const
attribute
      [-Wunused-value]
auto foo(T t) -> decltype(bar(), bool())
                          ^~~
sfinae.cc:8:27: warning: ignoring return value of function declared with const
attribute
      [-Wunused-value]
auto foo(T t) -> decltype(bar(), bool())
                          ^~~
2 warnings generated.

Likewise with 3.5.

$ clang++-mp-3.4 --version
clang version 3.4 (tags/RELEASE_34/final)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
$ clang++-mp-3.5 --version
clang version 3.5 (trunk 198565)
Target: x86_64-apple-darwin13.0.0
Thread model: posix


Btw, I don't know if clang has something similar to gcc's
don't_ignore_the_return_value attribute, but there's probably the same issue.</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>