<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 - sfinae discrepancy vs gcc"
href="https://bugs.llvm.org/show_bug.cgi?id=40362">40362</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>sfinae discrepancy vs gcc
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>mib.bugzilla@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>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</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>