[Bug c++/68220] New: [5.2.1 Regression] Devirtualization ICE in record_target_from_binfo, at ipa-devirt.c:2389

2015-11-05 Thread sebastien.piat at epita dot fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68220

Bug ID: 68220
   Summary: [5.2.1 Regression] Devirtualization ICE in
record_target_from_binfo, at ipa-devirt.c:2389
   Product: gcc
   Version: 5.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: sebastien.piat at epita dot fr
  Target Milestone: ---

Created attachment 36653
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36653&action=edit
The preprocessed file.

The following piece of code causes an internal compiler error when compiled
with this command line : `g++-5 -O3 -std=c++11 ice.cc`.
With this version of g++-5 : Debian 5.2.1-21 and boost version 1.58.
I could not find any simpler way to cause this error, as removing any of the
elements of the given code solves the problem (even using symbol instead of
boost::variant).
Note that it works if compiled with optimization up to -O2 or with the flag
`-fno-devirtualize`.

The code:

#include 

struct symbol
{
  virtual ~symbol();
};

using Identifier = boost::variant;

struct Fragment
{
  virtual void foo() const = 0;
  virtual ~Fragment();
};

struct ProcFrag : Fragment
{
  ~ProcFrag() {}
  virtual void foo() const override;
  Identifier id;
};

struct Fragments
{
  ~Fragments()
  {
delete x;
  }
  Fragment* x;
};

Fragments fragments;

Fragment::~Fragment()
{}

The compilation output with `-v -save-temps` (I have attached the preprocessed
file):

Using built-in specs.
COLLECT_GCC=g++-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 5.2.1-21'
--with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs
--enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-5 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
--enable-libstdcxx-debug --enable-libstdcxx-time=yes
--with-default-libstdcxx-abi=new --enable-gnu-unique-object
--disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib
--disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 5.2.1 20151003 (Debian 5.2.1-21) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-std=c++11' '-Wall' '-Werror'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -E -quiet -v -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE ice.cc -mtune=generic -march=x86-64 -std=c++11
-Wall -Werror -O3 -fpch-preprocess -o ice.ii
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/5"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/5/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/5
 /usr/include/x86_64-linux-gnu/c++/5
 /usr/include/c++/5/backward
 /usr/lib/gcc/x86_64-linux-gnu/5/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/5/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-O3' '-std=c++11' '-Wall' '-Werror'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/5/cc1plus -fpreprocessed ice.ii -quiet -dumpbase
ice.cc -mtune=generic -march=x86-64 -auxbase ice -O3 -Wall -Werror -std=c++11
-version -o ice.s
GNU C++11 (Debian 5.2.1-21) version 5.2.1 20151003 (x86_64-linux-gnu)
compiled by GNU C version 5.2.1 20151003, GMP version 6.0.0, MPFR
version 3.1.3, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++11 (Debian 5.2.1-21) version 5.2.1 20151003 (x86_64-linux-gnu)
compiled by GNU C version 5.2.1 20151003, GMP version 6.0.0, MPFR
version 3.1.3, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 60de134094777aef87cb5f2c7eb1a063
ice.cc:35:2: internal compiler error: in record_target_from_binfo, 

[Bug c++/68938] New: [C++11] use of lambda before deduction of auto does not fail in templated function

2015-12-16 Thread sebastien.piat at epita dot fr
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68938

Bug ID: 68938
   Summary: [C++11] use of lambda before deduction of auto does
not fail in templated function
   Product: gcc
   Version: 5.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: sebastien.piat at epita dot fr
  Target Milestone: ---

When testing the following code with g++ the compilation fails with error
"use of ‘print’ before deduction of ‘auto’"

===
#include 

void bar()
{
  auto print = std::function([&print](int n){ print(n); });
  print(1);
}

int main()
{
  bar();
  return 0;
}
===

While the following code where the function is templated does compile.

===
#include 

template 
void bar()
{
  auto print = std::function([&print](int n){ print(n); });
  print(1);
}

int main()
{
  bar();
  return 0;
}
===

Compilation with clang++ fails in both cases with error:
"variable 'print' declared with 'auto' type cannot appear in its own
initializer"
It is my understanding that it should not work.
I have tested these with g++ version: Debian 5.2.1-21 and Debian 4.9.2-10.