public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "niteria at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/59374] New: -ftree-slp-vectorize breaks unique_ptr's move constructor
Date: Tue, 03 Dec 2013 00:02:00 -0000	[thread overview]
Message-ID: <bug-59374-4@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2013-12-03  0:02 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-03  0:02 niteria at gmail dot com [this message]
2013-12-03  9:23 ` [Bug tree-optimization/59374] [4.8/4.9 Regression] " rguenth at gcc dot gnu.org
2013-12-03 11:40 ` rguenth at gcc dot gnu.org
2013-12-03 11:47 ` rguenth at gcc dot gnu.org
2013-12-03 13:02 ` rguenth at gcc dot gnu.org
2013-12-05  9:12 ` rguenth at gcc dot gnu.org
2013-12-05  9:24 ` [Bug tree-optimization/59374] [4.8 " rguenth at gcc dot gnu.org
2014-01-10  9:34 ` [Bug tree-optimization/59374] [4.7/4.8/4.9 " rguenth at gcc dot gnu.org
2014-01-10 10:53 ` rguenth at gcc dot gnu.org
2014-01-10 13:08 ` rguenth at gcc dot gnu.org
2014-01-10 13:08 ` [Bug tree-optimization/59374] [4.7/4.8 " rguenth at gcc dot gnu.org
2014-05-22  9:06 ` rguenth at gcc dot gnu.org
2014-09-17 16:37 ` [Bug tree-optimization/59374] [4.8 " paolo.carlini at oracle dot com
2014-12-10 12:51 ` rguenth at gcc dot gnu.org
2014-12-19 13:34 ` jakub at gcc dot gnu.org
2015-06-23  8:47 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-59374-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).