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

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-16T23:21:11Z
Last change time
2018-10-19T05:58:20Z
Keywords
pull
Assigned to
No Owner
Creator
Andrei Alexandrescu

Comments

Comment #0 by andrei — 2013-11-16T23:21:11Z
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.
Comment #1 by ibuclaw — 2013-11-17T00:18:27Z
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...
Comment #2 by yebblies — 2013-11-17T03:37:46Z
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
Comment #3 by yebblies — 2013-11-17T03:41:14Z
And running this just found 3 more...
Comment #4 by yebblies — 2013-11-17T04:18:35Z
Comment #5 by github-bugzilla — 2013-11-17T05:51:35Z
Comment #6 by github-bugzilla — 2013-11-17T13:14:45Z
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
Comment #7 by pro.mathias.lang — 2018-10-19T05:58:20Z
This was fixed but not closed. Marking as WORKSFORME so it doesn't show up in the changelog.