<html>
<head>
<base href="http://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 --- - decltype(-9223372036854775808) is unsigned instead of signed"
href="http://llvm.org/bugs/show_bug.cgi?id=16983">16983</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>decltype(-9223372036854775808) is unsigned instead of signed
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</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++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hhinnant@apple.com
</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>#include <limits>
#include <memory>
#include <iostream>
#include <cxxabi.h>
#include <cstdlib>
template <typename T>
std::string
type_name()
{
typedef typename std::remove_reference<T>::type TR;
std::unique_ptr<char, void(*)(void*)> own
(
abi::__cxa_demangle(typeid(TR).name(), nullptr,
nullptr, nullptr),
std::free
);
std::string r = own != nullptr ? own.get() : typeid(TR).name();
if (std::is_const<TR>::value)
r += " const";
if (std::is_volatile<TR>::value)
r += " volatile";
if (std::is_lvalue_reference<T>::value)
r += "&";
else if (std::is_rvalue_reference<T>::value)
r += "&&";
return r;
}
int
main()
{
std::cout << std::numeric_limits<long long>::min() << '\n';
std::cout << -9223372036854775808 << '\n';
std::cout << static_cast<long long>(0x8000000000000000) << '\n';
std::cout << type_name<decltype(-9223372036854775808)>() << '\n';
}
I expect this program to compile and output:
-9223372036854775808
-9223372036854775808
-9223372036854775808
long long
or:
-9223372036854775808
-9223372036854775808
-9223372036854775808
long
(latter ok only in 64 bit mode).
Instead I'm getting a warning:
test.cpp:35:19: warning: integer constant is so large that it is unsigned
std::cout << -9223372036854775808 << '\n';
^
test.cpp:37:38: warning: integer constant is so large that it is unsigned
std::cout << type_name<decltype(-9223372036854775808)>() << '\n';
^
2 warnings generated.
And the output is:
-9223372036854775808
9223372036854775808
-9223372036854775808
unsigned long long</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>