This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/59713] New: unordered_map constructor / destructor / move


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59713

            Bug ID: 59713
           Summary: unordered_map constructor / destructor / move
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: victor.robertson.iv at gmail dot com

Created attachment 31769
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31769&action=edit
intermediate files

Running the sample program produces the following:

a.out(49621,0x7fff7df24310) malloc: *** error for object 0x7fa472c03880:
pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6

Sample program:

#include <unordered_map>

struct Foo : std::unordered_map<int,int> {
    using std::unordered_map<int, int>::unordered_map;
    // ~Foo() = default; // explicitly adding default destructor fixes the
problem
};

struct Bar {
    Bar(Foo f = {}) : _f(std::move(f)) {}
    // any of these constructors also work:
    // Bar(Foo f = Foo()) : _f(std::move(f)) {}
    // Bar(Foo f = {}) : _f(f) {}

    Foo _f;
};

int main() {
    Bar b;

    // The following code also works as expected
    // Foo f1 = {};
    // Foo f2 = std::move(f1);
}

Output from g++-4.9 -v:

Using built-in specs.
COLLECT_GCC=gcc-4.9
COLLECT_LTO_WRAPPER=/usr/local/Cellar/gcc49/4.9-20131229/libexec/gcc/x86_64-apple-darwin13.0.0/4.9.0/lto-wrapper
Target: x86_64-apple-darwin13.0.0
Configured with: ../configure --build=x86_64-apple-darwin13.0.0
--prefix=/usr/local/Cellar/gcc49/4.9-20131229
--enable-languages=c,c++,objc,obj-c++ --program-suffix=-4.9
--with-gmp=/usr/local/opt/gmp4 --with-mpfr=/usr/local/opt/mpfr2
--with-mpc=/usr/local/opt/libmpc08 --with-cloog=/usr/local/opt/cloog018
--with-isl=/usr/local/opt/isl011 --with-system-zlib
--enable-version-specific-runtime-libs --enable-libstdcxx-time=yes
--enable-stage1-checking --enable-checking=release --enable-lto
--disable-werror --enable-plugin --disable-nls --disable-multilib
Thread model: posix
gcc version 4.9.0 20131229 (experimental) (GCC) 

Compiler command: g++-4.9 -Wall -Wextra --std=c++11 gcctest.cpp
No compiler output during compilation.

I've attached the intermediate files as requested.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]