www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19300] New: cpp_(u)long(long) types trigger enum comparison

https://issues.dlang.org/show_bug.cgi?id=19300

          Issue ID: 19300
           Summary: cpp_(u)long(long) types trigger enum comparison error
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

cat > bug.d << CODE
import core.stdc.config : cpp_ulong, cpp_ulonglong, cpp_long, cpp_longlong;

bool bug(ulong a, long b)
{
    return a == b;
}

bool bug(cpp_ulong a, cpp_long b)
{
    return a == b;
}

bool bug(cpp_ulonglong a, cpp_longlong b)
{
    return a == b;
}
CODE
dmd -c bug.d
----
bug.d(15): Error: Comparison between different enumeration types __c_ulonglong
and __c_longlong; If this behavior is intended consider using
std.conv.asOriginalType
----

The exact error message depends on the platform.

The types should behave like any other signed/unsigned types w.r.t. comparison.

__c_ulonglong et.al. have been introduced as enums with magic mangling, thus
comparison triggers those enum comparison errors.

--
Oct 11 2018