Bug 51121 - std::make_pair and std::multimap result in duplicate std::pair destructors in assembly
Summary: std::make_pair and std::multimap result in duplicate std::pair destructors in...
Status: RESOLVED DUPLICATE of bug 44473
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-14 14:33 UTC by David Bustos
Modified: 2011-11-14 16:21 UTC (History)
0 users

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


Attachments
.ii file of problematic code (47.72 KB, text/plain)
2011-11-14 14:34 UTC, David Bustos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Bustos 2011-11-14 14:33:54 UTC
g++ generates bad assembly for this code:

-------------------------------
#include <decimal/decimal>
#include <map>
#include <string>

using std::decimal::decimal32;

int
main( int, char ** )
{
	std::multimap< decimal32, std::pair< std::string, decimal32 > >  m;

	decimal32 d1;
	std::string str;
	decimal32 d2;

	m.insert( std::make_pair( d1, std::make_pair( str, d2 )));

	return 0;
}
-------------------------------

Specifically, it says

$ g++ -c multimap_decimal.cpp
/tmp/cc2sQism.s: Assembler messages:
/tmp/cc2sQism.s:1690: Error: symbol `_ZNSt4pairIDfS_ISsDfEED2Ev' is already defined

That symbol is the destructor for std::pair< decimal32, std::pair< std::string, decimal32 > >.  It seems that g++ is instatiating a destructor for that type and  with the first decimal32 replaced with const decimal32 and giving both the same mangled name.  So it works if I change the m.insert() line to

	std::pair< const decimal32, std::pair< std::string, decimal32 > >
	    p( d1, std::make_pair( str, d2 ));
	m.insert( p );

.ii file attached.

$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6.1/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --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.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
Comment 1 David Bustos 2011-11-14 14:34:54 UTC
Created attachment 25817 [details]
.ii file of problematic code
Comment 2 Paolo Carlini 2011-11-14 16:21:08 UTC
Works fine in 4.6.2.

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