Bug 70100 - [5 Regression] ICE: in execute, at cfgexpand.c:6066
Summary: [5 Regression] ICE: in execute, at cfgexpand.c:6066
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 5.3.0
: P2 normal
Target Milestone: 6.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2016-03-05 21:44 UTC by Emil Eriksson
Modified: 2017-10-10 20:09 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 6.0
Known to fail:
Last reconfirmed: 2016-03-06 00:00:00


Attachments
Preprocessed source (261.55 KB, application/x-bzip2)
2016-03-05 21:44 UTC, Emil Eriksson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Emil Eriksson 2016-03-05 21:44:58 UTC
Created attachment 37877 [details]
Preprocessed source

Internal Compiler error as follows:

FAILED: /usr/local/bin/g++-5    -Wall -Werror -Wno-missing-braces -std=c++11 -g -I../include -MMD -MT examples/database/CMakeFiles/database.dir/main.cpp.o -MF examples/database/CMakeFiles/database.dir/main.cpp.o.d -o examples/database/CMakeFiles/database.dir/main.cpp.o -c ../examples/database/main.cpp
In file included from ../include/rapidcheck/state/gen/ExecCommands.h:46:0,
                 from ../include/rapidcheck/state.h:9,
                 from ../examples/database/main.cpp:2:
../include/rapidcheck/state/gen/ExecCommands.hpp: In member function 'rc::Gen<std::shared_ptr<const typename Cmd::CommandType> > rc::state::gen::detail::ExecOneOf<Cmd, Cmds>::operator()(const Args& ...) const [with Args = {DatabaseModel}; Cmd = Open; Cmds = {Close, Put, BeginWrite, ExecuteWrite, Get}; typename Cmd::CommandType = rc::state::Command<DatabaseModel, Database>]':
../include/rapidcheck/state/gen/ExecCommands.hpp:39:14: internal compiler error: in execute, at cfgexpand.c:6066
   Gen<CmdSP> operator()(const Args &... args) const {
              ^

../include/rapidcheck/state/gen/ExecCommands.hpp:39:14: internal compiler error: Abort trap: 6
g++-5: internal compiler error: Abort trap: 6 (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.


Included is preprocessed output.
Comment 1 Markus Trippelsdorf 2016-03-06 11:51:58 UTC
markus@x4 /tmp % cat main.ii
namespace std {
template <typename _Tp, _Tp> struct integral_constant {
  static constexpr _Tp value = 0;
};
template <typename _Tp> _Tp declval;
template <typename, typename>
struct is_same : integral_constant<bool, false> {};
template <typename _Tp> struct A { typedef _Tp type; };
template <typename _Tp> struct A<_Tp &> { typedef _Tp type; };
template <typename _Tp> struct B { typedef typename A<_Tp>::type type; };
template <bool> struct enable_if;
template <typename> struct C;
template <typename> struct D {};
template <typename _Tp, typename = C<_Tp>> struct F;
}
template <typename T> using Decay = typename std::B<T>::type;
namespace std {
struct G {
  G(int);
};
}
template <typename> struct Gen {
  template <typename Impl,
            typename = std::enable_if<std::is_same<Impl, int>::value>>
  Gen(Impl &&);
  struct H;
  template <typename> struct L;
  H *m_impl;
};
template <typename T> struct Gen<T>::H {};
template <typename T> template <typename Impl> struct Gen<T>::L : H {
  template <typename... Args> L(Args... args) : m_impl(args...), m_count(0) {
    m_impl(0, 0);
  }
  Impl m_impl;
  std::G m_count;
};
template <typename T>
template <typename Impl, typename>
Gen<T>::Gen(Impl &&impl) : m_impl(new L<Decay<Impl>>(impl)) {}
namespace state {
template <typename, typename> struct Command {
  using Model = int;
  using CommandType = Command;
};
template <typename CommandType> using Commands = std::F<std::D<CommandType>>;
template <typename MakeInitialState, typename Sut, typename GenFunc,
          typename = decltype(std::declval<MakeInitialState>)>
void check(MakeInitialState &&, Sut &, GenFunc &&);
namespace gen {
template <typename Cmd, typename MakeInitialState, typename GenerationFunc,
          typename = std::enable_if<
              std::is_same<MakeInitialState, typename Cmd::Model>::value>>
Gen<Commands<Cmd>> commands(MakeInitialState &&, GenerationFunc &&);
template <typename GenFunc> struct I {
  template <typename InitialStateArg, typename GenFuncArg>
  I(InitialStateArg, GenFuncArg);
  void operator()(int, int) { J(0, 0, m_genFunc, 0); }
  struct J {
    J(int, int, GenFunc, int) { m_genFunc(0); }
    GenFunc m_genFunc;
  };
  GenFunc m_genFunc;
};
template <typename Cmd, typename MakeInitialState, typename GenerationFunc,
          typename>
Gen<Commands<Cmd>> commands(MakeInitialState &&, GenerationFunc &&) {
  return I<Decay<GenerationFunc>>(0, 0);
}
}
template <typename MakeInitialState, typename Sut, typename GenFunc, typename>
void check(MakeInitialState &&, Sut &, GenFunc &&generationFunc) {
  using Model = Decay<decltype(0)>;
  gen::commands<Command<Model, Sut>>(0, generationFunc);
}
namespace gen {
template <typename Cmd> struct K {
  using CmdSP = std::D<typename Cmd::CommandType>;
  template <typename... Args> void operator()(Args... args) {
    using MakeFunc = CmdSP(...);
    MakeFunc makeFuncs;
    [=] { [=] { makeFuncs(args...); }; };
  }
};
template <typename Cmd> K<Cmd> execOneOfWithArgs();
}
}
using DbCommand = state::Command<int, int>;
struct Get : DbCommand {};
int main() {
  void db();
  check(0, db, state::gen::execOneOfWithArgs<Get>());
}

markus@x4 /tmp % /usr/x86_64-pc-linux-gnu/gcc-bin/5.3.1/g++ -std=c++14 -c main.ii
main.ii: In member function ‘void state::gen::K<Cmd>::operator()(Args ...) [with Args = {int}; Cmd = Get]’:
main.ii:79:36: internal compiler error: in execute, at cfgexpand.c:6069

Might be related to PR68798.
Comment 2 Richard Biener 2016-06-03 10:06:09 UTC
GCC 5.4 is being released, adjusting target milestone.
Comment 3 Jaak Ristioja 2017-08-08 16:00:02 UTC
(In reply to Markus Trippelsdorf from comment #1)
> template <typename Cmd> struct K {
>   using CmdSP = std::D<typename Cmd::CommandType>;
>   template <typename... Args> void operator()(Args... args) {
>     using MakeFunc = CmdSP(...);
>     MakeFunc makeFuncs;
>     [=] { [=] { makeFuncs(args...); }; };
>   }
> };
...
> main.ii: In member function ‘void state::gen::K<Cmd>::operator()(Args ...)
> [with Args = {int}; Cmd = Get]’:
> main.ii:79:36: internal compiler error: in execute, at cfgexpand.c:6069

We hit a similar case in our proprietary production code, which compiled with -O2 resulted in a segmentation fault, but when compiled with -O0, resulted in this ICE.

Here is a smaller test-case to trigger this ICE with -std=c++11 -O0:

    void b(int) {}

    template <typename ... Args>
    void f(Args && ... args) {
        [&] {
            [&] {
                b(args...);
            };
        };
    }

    int main() { f(2); }

// gcc (Gentoo Hardened 5.4.0-r3 p1.3, pie-0.6.5) 5.4.0

Dunno, if it is relevant, but here is some of the <censored> disassembly output at proprietary crash site with -O2 (attempting to read 1 byte from address 0x0, according to Valgrind):

   0x000000105aa024ab <+1643>:  mov    %rax,%rbx
   0x000000105aa024ae <+1646>:  movl   $0x1,0x8(%rax)
   0x000000105aa024b5 <+1653>:  movl   $0x1,0xc(%rax)                                                                                                                            
   0x000000105aa024bc <+1660>:  lea    0x2a7f35(%rip),%rax      #<vtable for std::_Sp_counted_ptr_inplace<MyClass, std::allocator<MyClass>, (__gnu_cxx::_Lock_policy)2>                                                                                                                  
=> 0x000000105aa024c3 <+1667>:  movzbl 0x0,%ecx
Comment 4 Jakub Jelinek 2017-10-10 14:37:57 UTC
Fixed with r228175 for 6.* and later, GCC 5 branch is being closed.
Comment 5 Jakub Jelinek 2017-10-10 20:09:33 UTC
Author: jakub
Date: Tue Oct 10 20:09:01 2017
New Revision: 253611

URL: https://gcc.gnu.org/viewcvs?rev=253611&root=gcc&view=rev
Log:
	PR middle-end/70100
	* g++.dg/opt/pr70100.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/opt/pr70100.C
Modified:
    trunk/gcc/testsuite/ChangeLog