[Issue 3604] extern(C) callable function with array parameters broken

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 10 10:31:48 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3604


Witold Baryluk <baryluk at smp.if.uj.edu.pl> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Platform|Other                       |x86


--- Comment #1 from Witold Baryluk <baryluk at smp.if.uj.edu.pl> 2009-12-10 10:31:47 PST ---
In, 2.032 (just tested) it returns:
$ ./bug3604 
input: 0 0
input.ptr: BFA00CB8
cast input: BFA00CB8
x = 0 0
x[0] = 0
x[1] = 0
ok
$

So not exactly what I written, but pipe is working.

So i tested it more precisly:

bug3604.d:
 extern(C) int tttc(int[2] x);
void main() {
   int[2] input;
   tttc(input);
}

bug3604c.c:
  #include <stdio.h>

  int tttc(int x[2]) {
    printf("just in C\n");
    printf("x=%p\n", x);
    printf("x[0]=%d\n", x[0]);
    printf("x[1]=%d\n", x[1]);
    printf("back from C\n");
  }

# gcc -c bug3604c.c
# dmd2.032 bug3604.d bug3604c.o
# ./bug3604
just in C
x=0xbf988ff8
x[0]=0
x[1]=0
back from C
# dmd2.037 bug3604.d bug3604c.o
# ./bug3604
just in C
x=(nil)
Segmentation fault
#

So it is regression.

In `strace` for "pipe" example I see for 2.032:
 pipe([3, 4])                            = 0
and for 2.037:
 pipe(0)                                 = -1 EFAULT (Bad address)

So it also passes NULL pointer (jiust like in tttc function) .

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


More information about the Digitalmars-d-bugs mailing list