[LLVMbugs] [Bug 12396] New: -ffreestanding affects name mangling in C++

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Mar 29 04:50:17 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=12396

             Bug #: 12396
           Summary: -ffreestanding affects name mangling in C++
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: Headers
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: glider at google.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


$ cat t.cc
#include <stdint.h>
extern void Foo(uintptr_t a);
void Bar(uintptr_t b) {
  Foo(b);
}

$ clang++   -c t.cc && nm t.o 
0000000000000020 s EH_frame0
0000000000000000 T __Z3Barm
0000000000000038 S __Z3Barm.eh
                 U __Z3Foom

$ clang++ -ffreestanding  -c t.cc && nm t.o 
0000000000000020 s EH_frame0
0000000000000000 T __Z3Bary
0000000000000038 S __Z3Bary.eh
                 U __Z3Fooy

Note the difference between the mangled names for Foo and Bar with
-ffreestanding and without it.

Without -ffreestanding uintptr_t is defined as unsigned long, while with
-ffreestanding it is unsigned long long:

$ clang++  -E -c t.cc -o t.ii && grep "uintptr_t\|uint64_t" t.ii | grep typedef
typedef unsigned long long uint64_t;
typedef uint64_t uint_least64_t;
typedef uint64_t uint_fast64_t;
typedef unsigned long uintptr_t;

$ clang++ -ffreestanding -E -c t.cc -o t.ii && grep "uintptr_t\|uint64_t" t.ii
| grep typedef
typedef unsigned long long int uint64_t;
typedef uint64_t uint_least64_t;
typedef uint64_t uint_fast64_t;
typedef uint64_t uintptr_t;


BTW GCC does not support -ffreestanding for C++:
$ g++ -ffreestanding  -c t.cc && nm t.o 
cc1plus: warning: command line option "-ffreestanding" is valid for C/ObjC but
not for C++
0000000000000020 s EH_frame0
0000000000000000 T __Z3Barm
0000000000000038 S __Z3Barm.eh
                 U __Z3Foom

$  g++   -c t.cc && nm t.o 
0000000000000020 s EH_frame0
0000000000000000 T __Z3Barm
0000000000000038 S __Z3Barm.eh
                 U __Z3Foom

But in both cases uintptr_t is unsigned long under GCC.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list