https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93643

            Bug ID: 93643
           Summary: Static function pointer inside inline function with
                    "C" linkage is not mangled
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: iucar at fedoraproject dot org
  Target Milestone: ---

Created attachment 47807
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47807&action=edit
Assembler

Consider the following example (a simplification of a real case):

$ cat test.cpp 
void* callback(const char* name);

extern "C" {

inline void f1()
{
        static void (*f)();
        f = (void(*)()) callback("f1");
        f();
}

inline void f2()
{
        static void (*f)();
        f = (void(*)()) callback("f2");
        f();
}

} // extern "C"

int main()
{
        f1();
        f2();
}
$ g++ -save-temps test.cpp
g++ -save-temps test.cpp 
test.s: Assembler messages:
test.s:41: Error: symbol `f' is already defined

As you can see in the attached test.s, symbol "f" for functions f1 and f2 is
not mangled, and thus collides. Previous versions of GCC produce mangled
identifiers _ZZ2f1E1f and _ZZ2f2E1f.

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/10/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap
--enable-languages=c,c++,fortran,objc,obj-c++,ada,go,d,lto --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info
--with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared
--enable-threads=posix --enable-checking=release --enable-multilib
--with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions
--enable-gnu-unique-object --enable-linker-build-id
--with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin
--enable-initfini-array --with-isl --enable-offload-targets=nvptx-none
--without-cuda-driver --enable-gnu-indirect-function --enable-cet
--with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 10.0.1 20200130 (Red Hat 10.0.1-0.7) (GCC)

Reply via email to