[Bug tree-optimization/59374] New: -ftree-slp-vectorize breaks unique_ptr's move constructor

niteria at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Dec 3 00:02:00 GMT 2013


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

            Bug ID: 59374
           Summary: -ftree-slp-vectorize breaks unique_ptr's move
                    constructor
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: niteria at gmail dot com

Created attachment 31358
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31358&action=edit
result of -save-temps

Test file (SmallCore.cpp):

#include <memory>
#include <iostream>

using namespace std;

class Foo {};
class Bar : public Foo {};

struct StlAllocator {
  StlAllocator() : alloc_(nullptr) {}
  explicit StlAllocator(void* p) : alloc_(p) {}
  void* alloc_;
};

struct BarDelete : public StlAllocator {
  void operator()(void*) const {}
};

struct FooDelete : public StlAllocator {
  FooDelete() = default;
  /* implicit */ FooDelete(const BarDelete& other) : StlAllocator(other.alloc_)
    {}
  void operator()(void*) const {}
};

unique_ptr<Bar, BarDelete> myalloc() {
  return unique_ptr<Bar, BarDelete>(new Bar);
}

void fun(const unique_ptr<Foo, FooDelete>& foo) {
  cout << "fun " << foo.get() << endl;
}

int main(int, char **) {
  std::unique_ptr<Foo, FooDelete> foo;
  std::unique_ptr<Bar, BarDelete> bar = myalloc();
  foo = std::move(bar);

  auto p = foo.get();
  cout << "p " << p << endl;
  if (p != foo.get()) {
    cout << "wtf" << endl;
    abort();
  }

  fun(foo);
  return 0;
}

Compiled with: g++ -std=c++11 -O -ftree-slp-vectorize SmallCore.cpp

Produces: 
$ ./a.out
p 0x602010
wtf
Aborted

Expected result (up to pointer address):
$ ./a.out
p 0x602010
fun 0x602010

Gcc versions:
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/data/users/bnitka/prefix/ --with-ppl
--with-cloog --enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-languages=c,c++
--disable-gnu-unique-object --enable-linker-build-id --with-gnu-as
--with-gnu-ld --disable-multilib --enable-libstdcxx-time
Thread model: posix
gcc version 4.8.1 (GCC)

Target: x86_64-unknown-linux-gnu
Configured with: ./configure --prefix=/data/users/bnitka/prefix/ --with-ppl
--with-cloog --enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-languages=c,c++
--disable-gnu-unique-object --enable-linker-build-id --with-gnu-as
--with-gnu-ld --disable-multilib --enable-libstdcxx-time
Thread model: posix
gcc version 4.9.0 20131202 (experimental) (GCC)

Works on:
gcc-4.7.1



More information about the Gcc-bugs mailing list