<html>
<head>
<base href="https://llvm.org/bugs/" />
</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 --- - ICE when using __underlying_type builtin trait in template alias"
href="https://llvm.org/bugs/show_bug.cgi?id=23421">23421</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>ICE when using __underlying_type builtin trait in template alias
</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>All
</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>daniel@octaforge.org
</td>
</tr>
<tr>
<th>CC</th>
<td>dgregor@apple.com, llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=14285" name="attach_14285" title="the generated source from clang to reproduce the ICE">attachment 14285</a> <a href="attachment.cgi?id=14285&action=edit" title="the generated source from clang to reproduce the ICE">[details]</a></span>
the generated source from clang to reproduce the ICE
Found a bug while trying stuff today. Using the __underlying_type trait in the
context of template alias triggers an ICE; wrapping it in a struct first and
then using that works fine. This happens on FreeBSD 11, with Clang 3.4 and
3.7-trunk.
The testcase:
-----
#include <stdio.h>
#include <type_traits>
/* this does not work */
template<typename T> using Foo = __underlying_type(T);
/* this works */
template<typename T> struct Test {
typedef __underlying_type(T) type;
};
template<typename T> using Bar = typename Test<T>::type;
/* testcase */
enum class Baz: short { FOO };
int main() {
printf("%d\n", std::is_same<short, Foo<Baz>>::value);
printf("%d\n", std::is_same<short, Bar<Baz>>::value);
return 0;
}
-----
"Foo" is the broken version. "Bar" is an equivalent working version. The error
message:
-----
q66@butts: /home/q66/octastd$ clang++-devel ice.cpp -o ice -std=c++11 -Wall
-Wextra
clang: error: unable to execute command: Bus error (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.7.0 (trunk)
Target: x86_64-portbld-freebsd11.0
Thread model: posix
clang: note: diagnostic msg: PLEASE submit a bug report to
<a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and
associated run script.
clang: note: diagnostic msg:
********************
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/ice-b463b2.cpp
clang: note: diagnostic msg: /tmp/ice-b463b2.sh
clang: note: diagnostic msg:
********************
-----
Here is the generated run script:
-----
# Crash reproducer for clang version 3.7.0 (trunk)
# Original command: "/usr/local/llvm-devel/bin/clang" "-cc1" "-triple"
"x86_64-portbld-freebsd11.0" "-emit-obj" "-mrelax-all" "-disable-free"
"-disable-llvm-verifier" "-main-file-name" "ice.cpp" "-mrelocation-model"
"static" "-mthread-model" "posix" "-mdisable-fp-elim" "-masm-verbose"
"-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64"
"-target-linker-version" "2.17.50" "-dwarf-column-info"
"-fno-unique-section-names" "-resource-dir"
"/usr/local/llvm-devel/bin/../lib/clang/3.7.0" "-internal-isystem"
"/usr/include/c++/v1" "-Wall" "-Wextra" "-std=c++11" "-fdeprecated-macro"
"-fdebug-compilation-dir" "/home/q66/octastd" "-ferror-limit" "19"
"-fmessage-length" "215" "-mstackrealign" "-fobjc-runtime=gnustep"
"-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option"
"-fcolor-diagnostics" "-o" "/tmp/ice-e9d9e7.o" "-x" "c++" "ice.cpp"
"/usr/local/llvm-devel/bin/clang" "-cc1" "-triple"
"x86_64-portbld-freebsd11.0" "-emit-obj" "-mrelax-all" "-disable-free"
"-disable-llvm-verifier" "-main-file-name" "ice.cpp" "-mrelocation-model"
"static" "-mthread-model" "posix" "-mdisable-fp-elim" "-masm-verbose"
"-mconstructor-aliases" "-munwind-tables" "-target-cpu" "x86-64"
"-target-linker-version" "2.17.50" "-dwarf-column-info"
"-fno-unique-section-names" "-Wall" "-Wextra" "-std=c++11" "-fdeprecated-macro"
"-ferror-limit" "19" "-fmessage-length" "215" "-mstackrealign"
"-fobjc-runtime=gnustep" "-fcxx-exceptions" "-fexceptions"
"-fdiagnostics-show-option" "-fcolor-diagnostics" "-x" "c++" "ice-b463b2.cpp"
-----
I attached the generated source.
If you need any more info, let me know.</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>