www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11532] New: Variadics using the C ABI should not accept D-specific types

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11532

           Summary: Variadics using the C ABI should not accept D-specific
                    types
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrei erdani.com


--- Comment #0 from Andrei Alexandrescu <andrei erdani.com> 2013-11-16 23:21:11
PST ---
The ABI for C variadics (e.g. printf and friends) does not understand D data
types, in particular slices and fixed-size arrays.

We should reject statically any passing of D-specific data through C-style
variadics.

This has been a very nagging issue during a port of a large C codebase.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 16 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11532


Iain Buclaw <ibuclaw ubuntu.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ibuclaw ubuntu.com


--- Comment #1 from Iain Buclaw <ibuclaw ubuntu.com> 2013-11-17 00:18:27 PST ---
They do map to C ABI, just not in the way which you may likely expect.

I'd +1 fixed size arrays, as it is not obvious that eg: int[4] is passed as
struct { int a,b,c,d; }

Though I'd really like to make some sort of exception to the va_list type (in
particular, for x86_64 and PPC). That has been one nagging problem I haven't
yet got round to...

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11532


yebblies <yebblies gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull
                 CC|                            |yebblies gmail.com


--- Comment #2 from yebblies <yebblies gmail.com> 2013-11-17 22:37:46 EST ---
Yeah, this one is a huge pain for DDMD, people are constantly adding ?: with
string literals inside printfs.

https://github.com/D-Programming-Language/dmd/pull/2797

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11532



--- Comment #3 from yebblies <yebblies gmail.com> 2013-11-17 22:41:14 EST ---
And running this just found 3 more...

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11532



--- Comment #4 from yebblies <yebblies gmail.com> 2013-11-17 23:18:35 EST ---
And a couple of cases left in phobos:

https://github.com/D-Programming-Language/phobos/pull/1698

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11532



--- Comment #5 from github-bugzilla puremagic.com 2013-11-17 05:51:35 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/48063576235217b169efa4343008d08f4a6790a7
Fixup for issue 11532

https://github.com/D-Programming-Language/phobos/commit/b2c6179854eee67387e5d41f317269c4c6b8b58e
Merge pull request #1698 from yebblies/issue11532

[trivial] Fixup for issue 11532

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2013
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11532



--- Comment #6 from github-bugzilla puremagic.com 2013-11-17 13:14:45 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/419096e305eff06ef889a8d1a23660d4f3d70eb4
Fix Issue 11532 - Variadics using the C ABI should not accept D-specific types

https://github.com/D-Programming-Language/dmd/commit/56544eddd0f4536fd7f1f6d4adb82e3fea9ca8d0
Merge pull request #2797 from yebblies/issue11532

Issue 11532 - Variadics using the C ABI should not accept D-specific types

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 17 2013