public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/61143] New: Arithmetic exception on emplacing into unordered_map moved out
@ 2014-05-10 23:46 felix at fontein dot de
  2014-05-11  7:30 ` [Bug libstdc++/61143] " felix at fontein dot de
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: felix at fontein dot de @ 2014-05-10 23:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 61143
           Summary: Arithmetic exception on emplacing into unordered_map
                    moved out
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: felix at fontein dot de

Created attachment 32775
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32775&action=edit
Preprocessed sample code.

If I try to emplace a new element into an unordered_map<> whose content was
moved out before, a floating point exception is raised. Sample code:

#include <unordered_map>

int main()
{
    std::unordered_map<int, int> a;
    a.emplace(1, 1);
    std::unordered_map<int, int> b = std::move(a);
    a.emplace(1, 1);
}

The problem is that apparently the number of buckets is set to zero, and
std::__detail::_Hash_code_base<...>::_M_bucket_index tries to compute the hash
code modulo the number of buckets.

Tested with GCC version 4.9.0. If I recall correctly, the above example did
work with an older version of GCC/libstdc++ (I think GCC 4.8.x).

Details: GCC 4.9 on Arch Linux; gcc -v yields:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc/src/gcc-4.9-20140507/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-cloog-backend=isl --disable-cloog-version-check --enable-lto
--enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu
--disable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 4.9.0 20140507 (prerelease) (GCC) 

Command line to trigger bug: g++ -std=c++11 -g -o test test.cpp
(and subsequent execution of ./test)


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2014-05-23 19:35 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-10 23:46 [Bug libstdc++/61143] New: Arithmetic exception on emplacing into unordered_map moved out felix at fontein dot de
2014-05-11  7:30 ` [Bug libstdc++/61143] " felix at fontein dot de
2014-05-11 10:03 ` [Bug libstdc++/61143] [4.9/4.10 Regression] " redi at gcc dot gnu.org
2014-05-11 11:02 ` daniel.kruegler at googlemail dot com
2014-05-11 14:06 ` redi at gcc dot gnu.org
2014-05-12  6:43 ` fdumont at gcc dot gnu.org
2014-05-12 10:01 ` redi at gcc dot gnu.org
2014-05-12 10:07 ` glisse at gcc dot gnu.org
2014-05-13  9:19 ` redi at gcc dot gnu.org
2014-05-13  9:32 ` redi at gcc dot gnu.org
2014-05-13 15:26 ` felix at fontein dot de
2014-05-13 20:14 ` fdumont at gcc dot gnu.org
2014-05-13 20:48 ` redi at gcc dot gnu.org
2014-05-21 19:51 ` fdumont at gcc dot gnu.org
2014-05-23 19:35 ` fdumont at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).