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

dave287091@gmail.com changed:

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

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

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla@digitalmars.com

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
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, 2022
https://issues.dlang.org/show_bug.cgi?id=22665

--- Comment #2 from dave287091@gmail.com ---
(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, 2022
https://issues.dlang.org/show_bug.cgi?id=22665

--- Comment #3 from dave287091@gmail.com ---
(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, 2022
https://issues.dlang.org/show_bug.cgi?id=22665

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
"shall be capable of representing the values of" is not the same as being the same type.

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

Walter Bright <bugzilla@digitalmars.com> 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, 2022
https://issues.dlang.org/show_bug.cgi?id=22665

Dlang Bot <dlang-bot@dlang.rocks> changed:

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

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
@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, 2022
https://issues.dlang.org/show_bug.cgi?id=22665

--- Comment #6 from dave287091@gmail.com ---
(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, 2022
https://issues.dlang.org/show_bug.cgi?id=22665

Dlang Bot <dlang-bot@dlang.rocks> changed:

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

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
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

--