Bug 57227 - Two function with identical signature but different calling convention seem to be symbol-encoded by the same string
Summary: Two function with identical signature but different calling convention seem t...
Status: RESOLVED DUPLICATE of bug 44282
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-09 13:23 UTC by ondrej.kolacek
Modified: 2021-07-27 02:20 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ondrej.kolacek 2013-05-09 13:23:50 UTC
Consider following snippet in which we specialize Decider template with dummyd and dummye functions which only differ in calling convention:

int dummyd()
{
    return 110;
}

int __attribute__((__stdcall__)) dummye()
{
    return 1;
}

template<typename T>
bool Decider(T && )
{
    return true;
}

int main()
{
    Decider(dummyd);
    Decider(dummye);
    return 0;
}

trying to compile this results into assembler error:
test2.s: Assembler messages:
test2.s:112: Error: symbol `_Z7DeciderIRFivEEbOT_' is already defined

It seems to me that while g++ knows about dummyd and dummye having different calling convention, it hands to the assembler two equal symbol names.

I have seen one bug which may be duplicate of this - bug 29328, but
1) the issue may be slightly different, as in my case compiler evidently treats the two specializations as different types
2) the bug is rotting there for 7 years now so making a new one could stir things up

g++-4.7 -v -save-temps -g test2.cpp -std=c++11 -m32 -Wall -Wextra
Using built-in specs.
COLLECT_GCC=g++-4.7
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.7/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.7.2-5' --with-bugurl=file:///usr/share/doc/gcc-4.7/README.Bugs --enable-languages=c,c++,go,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.7 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --with-arch-32=i586 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.7.2 (Debian 4.7.2-5)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-g' '-std=c++11' '-m32' '-Wall' '-Wextra' '-shared-libgcc' '-mtune=generic' '-march=i586'
 /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1plus -E -quiet -v -imultilib 32 -imultiarch i386-linux-gnu -D_GNU_SOURCE test2.cpp -m32 -mtune=generic -march=i586 -std=c++11 -Wall -Wextra -g -fworking-directory -fpch-preprocess -o test2.ii
ignoring nonexistent directory "/usr/local/include/i386-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.7
 /usr/include/c++/4.7/x86_64-linux-gnu/32
 /usr/include/c++/4.7/backward
 /usr/lib/gcc/x86_64-linux-gnu/4.7/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed
 /usr/include/i386-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-g' '-std=c++11' '-m32' '-Wall' '-Wextra' '-shared-libgcc' '-mtune=generic' '-march=i586'
 /usr/lib/gcc/x86_64-linux-gnu/4.7/cc1plus -fpreprocessed test2.ii -quiet -dumpbase test2.cpp -m32 -mtune=generic -march=i586 -auxbase test2 -g -Wall -Wextra -std=c++11 -version -o test2.s
GNU C++ (Debian 4.7.2-5) version 4.7.2 (x86_64-linux-gnu)
        compiled by GNU C version 4.7.2, GMP version 5.0.5, MPFR version 3.1.0-p10, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (Debian 4.7.2-5) version 4.7.2 (x86_64-linux-gnu)
        compiled by GNU C version 4.7.2, GMP version 5.0.5, MPFR version 3.1.0-p10, MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 66d178dd81da8c975e003e06d9f5e782
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-g' '-std=c++11' '-m32' '-Wall' '-Wextra' '-shared-libgcc' '-mtune=generic' '-march=i586'
 as -v --32 -o test2.o test2.s
GNU assembler version 2.22 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.22
test2.s: Assembler messages:
test2.s:112: Error: symbol `_Z7DeciderIRFivEEbOT_' is already defined
[kolaceko@lce:~/proj/2/avg/mk]$
Comment 1 Andrew Pinski 2021-07-27 02:20:23 UTC
Dup of bug 44282.

*** This bug has been marked as a duplicate of bug 44282 ***