https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90775

            Bug ID: 90775
           Summary: A inconsistent compilation result
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhonghao at pku dot org.cn
  Target Milestone: ---

My g++ is 10.0.0, and my code is as follows:

#include <iterator>
#include <type_traits>
struct S {};
int begin(S);
template<class T> std::true_type has_cbegin(decltype(std::cbegin(T{})));
template<class T> std::false_type has_cbegin(...);
static_assert(!decltype(has_cbegin<S>(0))::value);

When compiling with -c -std=c++14, it accepts the code. However, when compiling
with -c -std=c++11 or -c -std=c++0x

/home/haozhong/project/approach/compilerpara/llvm/tmp/llvm_28927/code0.c.cpp:5:59:error:‘cbegin’
is not a member of ‘std’; did you mean ‘begin’?
    5 | template<class T> std::true_type
has_cbegin(decltype(std::cbegin(T{})));
      |                                                           ^~~~~~
      |                                                           begin
/home/haozhong/project/approach/compilerpara/llvm/tmp/llvm_28927/code0.c.cpp:5:59:
error:‘cbegin’ is not a member of ‘std’; did you mean ‘begin’?
    5 | template<class T> std::true_type
has_cbegin(decltype(std::cbegin(T{})));
      |                                                           ^~~~~~
      |                                                           begin
/home/haozhong/project/approach/compilerpara/llvm/tmp/llvm_28927/code0.c.cpp:7:15:
error: static assertion failed
    7 | static_assert(!decltype(has_cbegin<S>(0))::value);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Something wrong with -std=c++14?

Reply via email to