www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8887] New: static arrays should not be passed by value in extern C/C++ functions

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

           Summary: static arrays should not be passed by value in extern
                    C/C++ functions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: andrej.mitrovich gmail.com
        ReportedBy: andrej.mitrovich gmail.com



13:01:56 PDT ---
extern(C) void fail(int[4] x);
extern(C) int[4] fail2();
extern(C++) void fail3(int[4] x);
extern(C++) int[4] fail4();

These should fail since C/C++ compilers always pass arrays by pointer to first
element.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 24 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8887


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

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



16:32:34 PST ---
Walter has rejected this.
https://github.com/D-Programming-Language/dmd/pull/1215#issuecomment-9770031

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 04 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8887


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



From Walter:
https://github.com/D-Programming-Language/dmd/pull/1215#issuecomment-9770031

 This change breaks existing code,
What existing code? (And the D1 code that relies on is now broken).
 requires an awkward workaround for existing uses,
Even if they exist they are niche usages, right? It's better to keep the D semantics saner/cleaner. As Python Zen says, few special cases are not special enough to justify this hole in the D type system. In D it's important not just to fix holes in the design of C, but also holes coming from changes between D1 and D2. I think this type system hole was an oversight while D2 fixed-sized array semantics argument pass changed.
 and has only a marginal benefit.
The benefit is helping all future C programmers that don't remember that D passes fixed-sized arrays by value, for years and years to come. From my experience I've seen that lot of people don't remember that. Those C programmers will write extern(C) and they will come in the D.learn group to ask why their code doesn't work. I will try to keep count how many such posts will appear in D.learn. One of the design rules of D is that D acts as C or it gives an error. In this case it silently passes wrong data to C functions, so here there's a breaking of the D design rules. So I think this hole should be fixed. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 04 2012