<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 - GCC Compat attribute 'mode' doesn't work on type-aliases"
href="https://bugs.llvm.org/show_bug.cgi?id=50391">50391</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>GCC Compat attribute 'mode' doesn't work on type-aliases
</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>Linux
</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>erich.keane@intel.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>Low priority since 'mode' is horrible and not particularly well used.
See: <a href="https://godbolt.org/z/jGEesvWeT">https://godbolt.org/z/jGEesvWeT</a>
typedef int __attribute__((mode(QI))) Type;
using AliasTy = int __attribute__((mode(QI)));
template<typename T>
void foo(){}
int main() {
foo<Type>();
foo<AliasTy>();
foo<int>();
}
Presumably the attribute should work the same in the typedef as the type alias,
but it doesnt.
The assembly is:
call void foo<signed char>()
call void foo<int>()
call void foo<int>()
instead of the 2nd also being a signed-char.
It is just silently ignored in a type-alias entirely, even for SEMA:
<a href="https://godbolt.org/z/YP9q3o1qv">https://godbolt.org/z/YP9q3o1qv</a>
Note how we get an error for the 1st line, but not the 2nd.
typedef int __attribute__((mode(DF))) Type;
using AliasTy = int __attribute__((mode(DF)));
template<typename T>
void foo(){}
int main() {
foo<Type>();
foo<AliasTy>();
foo<int>();
}
<source>:3:28: error: type of machine mode does not match type of base type
typedef int __attribute__((mode(DF))) Type;
We even don't bother to check the contents at all!
<a href="https://godbolt.org/z/Mrfxqzaba">https://godbolt.org/z/Mrfxqzaba</a></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>