Thread overview
[Issue 22665] ImportC: qualified enum values should be of enum type on the D side, not int
[Issue 22665] ImportC: enums are not "implicitly converting" to their own type.
Jan 13
Dlang Bot
Jan 14
Dlang Bot
January 11
https://issues.dlang.org/show_bug.cgi?id=22665

[email protected] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ImportC

--
January 13
https://issues.dlang.org/show_bug.cgi?id=22665

Walter Bright <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #1 from Walter Bright <[email protected]> ---
The trouble here is that in C11, 6.7.2.2-3 says "The identifiers in an enumerator list are declared as constants that have type int". I'll see what I can do.

--
January 13
https://issues.dlang.org/show_bug.cgi?id=22665

--- Comment #2 from [email protected] ---
(In reply to Walter Bright from comment #1)
> The trouble here is that in C11, 6.7.2.2-3 says "The identifiers in an enumerator list are declared as constants that have type int". I'll see what I can do.

6.7.2.4 specifies that "Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined) but shall be capable of representing the values of all the members of the enumeration.”, so the value will always fit.

--
January 13
https://issues.dlang.org/show_bug.cgi?id=22665

--- Comment #3 from [email protected] ---
(In reply to dave287091 from comment #2)
> (In reply to Walter Bright from comment #1)
> ...
> 6.7.2.4
> ...

Sorry, 6.7.2.2-4

--
January 13
https://issues.dlang.org/show_bug.cgi?id=22665

--- Comment #4 from Walter Bright <[email protected]> ---
"shall be capable of representing the values of" is not the same as being the same type.

--
January 13
https://issues.dlang.org/show_bug.cgi?id=22665

Walter Bright <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|ImportC: enums are not      |ImportC: qualified enum
                   |"implicitly converting" to  |values should be of enum
                   |their own type.             |type on the D side, not int

--
January 13
https://issues.dlang.org/show_bug.cgi?id=22665

Dlang Bot <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #5 from Dlang Bot <[email protected]> ---
@WalterBright created dlang/dmd pull request #13520 "fix Issue 22665 - ImportC: qualified enum values should be of enum ty…" fixing this issue:

- fix Issue 22665 - ImportC: qualified enum values should be of enum type on the D side, not int

https://github.com/dlang/dmd/pull/13520

--
January 13
https://issues.dlang.org/show_bug.cgi?id=22665

--- Comment #6 from [email protected] ---
(In reply to Walter Bright from comment #4)
> "shall be capable of representing the values of" is not the same as being the same type.

Yes, but it means that the implicit conversion is safe, in the same way that converting a short to an int is safe, or that (int & 0x7f) is allowed to implicitly convert to byte.

--
January 14
https://issues.dlang.org/show_bug.cgi?id=22665

Dlang Bot <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Dlang Bot <[email protected]> ---
dlang/dmd pull request #13520 "fix Issue 22665 - ImportC: qualified enum values should be of enum ty…" was merged into master:

- 0cff8651a892fa3fbfb8564e83c75ac214f7c585 by Walter Bright:
  fix Issue 22665 - ImportC: qualified enum values should be of enum type on
the D side, not int

https://github.com/dlang/dmd/pull/13520

--