Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

std::is_same wrong result for captured reference value inside a lambda #35724

Open Quuxplusone opened 6 years ago

Quuxplusone commented 6 years ago
Bugzilla Link PR36753
Status NEW
Importance P enhancement
Reported by Jürgen Peter Messerer (juergen.messerer@sunrise.ch)
Reported on 2018-03-15 08:27:27 -0700
Last modified on 2018-03-15 13:41:24 -0700
Version unspecified
Hardware PC Linux
CC anders@knatten.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Hi

lately I tried to solve the question 127 from
http://cppquiz.org/quiz/question/127

And I realized that the program compiled with clang gives another result as
compiled with gcc. I tried every available version on wandbox.org with the same
result.

According to the maintainer of cppquiz.org there is a bug filed in gcc.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66672

It seems that clang did it right with C++11 but not with greater version.
Can someone confirm or decline this statement?

Thanks for clarification.

Best regards
Juergen

clang output: 00100
gcc   output: 01000

//----------------------------------------------------------------------
#include <iostream>
#include <type_traits>

using namespace std;

int main()
{
  int i, &j = i;
  [=]
  {
    cout << is_same<decltype    ((j)),     int         >::value
         << is_same<decltype   (((j))),    int      &  >::value
         << is_same<decltype  ((((j)))),   int const&  >::value
         << is_same<decltype (((((j))))),  int      && >::value
         << is_same<decltype((((((j)))))), int const&& >::value;
  }();
}
Quuxplusone commented 6 years ago

It seems that this bug is related to https://bugs.llvm.org/show_bug.cgi?id=35423

Quuxplusone commented 6 years ago

Hi, I'm the previously mentioned maintainer of cppquiz.org.

After reading Richard Smith's comment at https://bugs.llvm.org/show_bug.cgi?id=35423#c2, I think clang is correct and gcc is wrong even given the latest draft.

This bug can probably be closed for the same reason as 35423.