[Issue 23059] importC: calls to D template functions don't convert some argument types

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 30 03:55:48 UTC 2022


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

Walter Bright <bugzilla at digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla at digitalmars.com
         Resolution|---                         |WONTFIX
           Severity|normal                      |enhancement

--- Comment #1 from Walter Bright <bugzilla at digitalmars.com> ---
1. As you note, unlike C, D doesn't do implicit integer narrowing conversions.
Here, C is calling D templates, and isn't doing those conversions. Should they,
is an interesting topic. I suggest that D templates are written to work with D
style conversions. Adding a special case for C may wind up doing things like
unexpectedly instantiate the wrong template. I am concerned this may be risky,
and it may be difficult to set up templates that will work with both D and C.

Fortunately, the workarounds from the C side are simple - a cast. The
accommodations for the D side are also simple - add more overloads that take
the larger types, cast them, then forward to the function with the narrower
types.

2. This is similar, allowing the C implicit conversion of integers to pointers.
Frankly, this could be letting a cat loose in an aviary. I expect it would be
pretty risky, and again the accommodations are simple, so it is not worth it to
adjust the semantics.

We should be in good shape here without risking adding C's error prone implicit
conversions on the D side.

--


More information about the Digitalmars-d-bugs mailing list