[llvm-bugs] [Bug 40362] New: sfinae discrepancy vs gcc

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jan 17 09:41:51 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40362

            Bug ID: 40362
           Summary: sfinae discrepancy vs gcc
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mib.bugzilla at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

This test case gets an error with clang but it's OK with gcc8. Is this a clang
bug?
clang++ -c -std=c++17 test.cpp
test.cpp:14:75: warning: incompatible integer to pointer conversion assigning
to
      'int *' from 'long' [-Wint-conversion]
  ...U> typename enable_if<(sizeof(create_a<T>() -= create_a<U>(), 1) > 0),
y...
                                                 ^  ~~~~~~~~~~~~~
test.cpp:16:17: note: in instantiation of template class 'has_minus_assign<int
*,
      int *>' requested here
static_assert((!has_minus_assign<int*>::value), "(!has_minus_assign<int*...
                ^
test.cpp:16:1: error: static_assert failed due to requirement
      '!has_minus_assign<int *, int *>::value'
      "(!has_minus_assign<int*>::value)"
static_assert((!has_minus_assign<int*>::value), "(!has_minus_assign<int*...
^              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 1 error generated.
$ g++ -c -std=c++17 test.cpp
$ cat test.cpp
typedef char yes_type;
struct no_type { char data[2]; };
template<typename T> T create_a();
template<typename T> struct type { };
template<bool, typename T = void> struct enable_if { typedef T type; };
template<typename T> struct enable_if<false, T> { };
struct Y {
  Y& operator=(Y&);
};
struct X {
  X& operator-=(X);
};
struct Z { };
template<typename T, typename U> typename enable_if<(sizeof(create_a<T>() -=
create_a<U>(), 1) > 0), yes_type>::type check_has_minus_assign(type<T>,
type<U>); no_type check_has_minus_assign(...); template<typename T, typename U
= T> struct has_minus_assign { static const bool value =
(sizeof(check_has_minus_assign(type<T&>(), type<U>())) == sizeof(yes_type)); };
X& operator-=(X&, Y);
static_assert((!has_minus_assign<int*>::value),
"(!has_minus_assign<int*>::value)");

--Melanie Blower
I work for Intel on the C++ compiler

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190117/bba29115/attachment-0001.html>


More information about the llvm-bugs mailing list