www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15736] New: clang vs gcc-42 on osx 10.11 (el capitan)

https://issues.dlang.org/show_bug.cgi?id=15736

          Issue ID: 15736
           Summary: clang vs gcc-42 on osx 10.11 (el capitan)
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: braddr puremagic.com

The dmd unittest cppa.d fails on darwin_64_32 with the default installed
compiler (clang 7.0.2).  Reverting to the same compiler the other auto-testers
are using, gcc 4.2 works.  The problem reduces to:

--- cppb.cpp ---
#include <stdio.h>
#include <assert.h>
#include <exception>

struct S13956
{
};

void check13956(S13956 arg0, int arg1);

void func13956(S13956 arg0, int arg1)
{
    check13956(arg0, arg1);
}
---

--- foo.d ---
import core.stdc.stdio;
import core.stdc.stdarg;
import core.stdc.config;


struct S13956
{
}

extern(C++) void func13956(S13956 arg0, int arg1);

extern(C++) void check13956(S13956 arg0, int arg1)
{
    printf("1:\n");
    assert(arg0 == S13956());
    printf("2: %d\n", arg1);
    assert(arg1 == 1);
    printf("3:\n");
}

void test13956()
{
    func13956(S13956(), 1);
}


void main()
{
    test13956();

    printf("Success\n");
}
---

The asm code for the two cpp functions:

--- cppb-gcc-42.o ---
Disassembly of section __TEXT,__text:
__Z9func139566S13956i:
       0:       55      pushl   %ebp
       1:       89 e5   movl    %esp, %ebp
       3:       83 ec 28        subl    $40, %esp
       6:       8b 45 0c        movl    12(%ebp), %eax
       9:       89 44 24 04     movl    %eax, 4(%esp)
       d:       0f b6 45 f7     movzbl  -9(%ebp), %eax
      11:       88 04 24        movb    %al, (%esp)
      14:       e8 e7 ff ff ff  calll   -25 <__Z9func139566S13956i>
      19:       c9      leave
      1a:       c3      retl
---

--- cppb-clang.o ---
Disassembly of section __TEXT,__text:
__Z9func139566S13956i:
       0:       55      pushl   %ebp
       1:       89 e5   movl    %esp, %ebp
       3:       83 ec 18        subl    $24, %esp
       6:       8b 45 08        movl    8(%ebp), %eax
       9:       89 45 f4        movl    %eax, -12(%ebp)
       c:       8b 45 f4        movl    -12(%ebp), %eax
       f:       89 04 24        movl    %eax, (%esp)
      12:       e8 e9 ff ff ff  calll   -23 <__Z9func139566S13956i>
      17:       83 c4 18        addl    $24, %esp
      1a:       5d      popl    %ebp
      1b:       c3      retl
---

--
Feb 29 2016