Thread overview
[Issue 20688] Wrong code when linking to C complex number functions
Mar 20, 2020
Vladimir Panteleev
Aug 29, 2020
Walter Bright
Sep 07, 2020
Walter Bright
Sep 07, 2020
Vladimir Panteleev
Sep 07, 2020
Vladimir Panteleev
Sep 07, 2020
Walter Bright
Sep 07, 2020
Vladimir Panteleev
Sep 07, 2020
Walter Bright
Sep 07, 2020
Walter Bright
March 20, 2020
https://issues.dlang.org/show_bug.cgi?id=20688

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code

--
August 29, 2020
https://issues.dlang.org/show_bug.cgi?id=20688

Walter Bright <bugzilla@digitalmars.com> changed:

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

--
September 07, 2020
https://issues.dlang.org/show_bug.cgi?id=20688

Walter Bright <bugzilla@digitalmars.com> changed:

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

--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> ---
The %f format is for doubles, and creal/cimag return reals. To fix:

  printf("%f+%fi\n", cast(double)creal(r), cast(double)cimag(r));

which prints:

  4.000000+0.000000i

--
September 07, 2020
https://issues.dlang.org/show_bug.cgi?id=20688

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |---

--- Comment #2 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
(In reply to Walter Bright from comment #1)
> The %f format is for doubles, and creal/cimag return reals.

So: https://github.com/dlang/druntime/blob/master/src/core/stdc/complex.d#L153

creal is weirdly an alias to "complex" instead of a function.

> To fix:

No, still a problem on Linux/x86_64.

--
September 07, 2020
https://issues.dlang.org/show_bug.cgi?id=20688

--- Comment #3 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
Demonstration: https://run.dlang.io/is/haL0K3

--
September 07, 2020
https://issues.dlang.org/show_bug.cgi?id=20688

--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> ---
It works correctly when I try it with master. Perhaps this is because I have fixed other bugs regarding structs in the meantime.

--
September 07, 2020
https://issues.dlang.org/show_bug.cgi?id=20688

Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |WORKSFORME

--- Comment #5 from Vladimir Panteleev <dlang-bugzilla@thecybershadow.net> ---
Confirmed, fixed in master. Thanks!

--
September 07, 2020
https://issues.dlang.org/show_bug.cgi?id=20688

--- Comment #6 from Walter Bright <bugzilla@digitalmars.com> ---
I added a test case to ensure it.

--
September 07, 2020
https://issues.dlang.org/show_bug.cgi?id=20688

--- Comment #7 from Walter Bright <bugzilla@digitalmars.com> ---
https://github.com/dlang/dmd/pull/11710

--