http://llvm.org/bugs/show_bug.cgi?id=16983

            Bug ID: 16983
           Summary: decltype(-9223372036854775808) is unsigned instead of
                    signed
           Product: clang
           Version: trunk
          Hardware: Macintosh
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

#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

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to