https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96353

            Bug ID: 96353
           Summary: GCC internal compiler error: in implicitly_declare_fn,
                    at cp/method.c:2058 when using coverage
           Product: gcc
           Version: 9.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wallguide-software at yahoo dot com
  Target Milestone: ---

#gcc bug report (internal compiler error when using coverage)


##### NB: Using this command line, the file compiles! #######
g++ -o test\TestAll_Of.o -c -Wall -Wextra -O0 -std=c++17 -Werror -Iapplib
-Izlib -Itest\testenv test\TestAll_Of.cpp


##### This is the compiler failing: #######
g++ -v -save-temps -o test\TestAll_Of.o -c -Wall -Wextra -O0 -std=c++17 -Werror
--coverage -fno-elide-constructors -fno-default-inline -Iapplib -Izlib
-Itest\testenv test\TestAll_Of.cpp
Using built-in specs.
COLLECT_GCC=g++
Target: x86_64-w64-mingw32
Configured with: ../src/configure --enable-languages=c,c++
--build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32
--target=x86_64-w64-mingw32 --disable-multilib --prefix=/c/temp/gcc/dest
--with-sysroot=/c/temp/gcc/dest --disable-libstdcxx-pch
--disable-libstdcxx-verbose --disable-nls --disable-shared
--disable-win32-registry --with-tune=haswell --enable-threads=posix
--enable-libgomp
Thread model: posix
gcc version 9.2.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'test\TestAll_Of.o' '-c' '-Wall'
'-Wextra' '-O0' '-std=c++17' '-Werror' '-coverage' '-fno-elide-constructors'
'-I' 'applib' '-I' 'zlib' '-I' 'test\testenv' '-mtune=haswell' '-march=x86-64'
 d:/mingw17_1/bin/../libexec/gcc/x86_64-w64-mingw32/9.2.0/cc1plus.exe -E -quiet
-v -I applib -I zlib -I test\testenv -iprefix
d:\mingw17_1\bin\../lib/gcc/x86_64-w64-mingw32/9.2.0/ -D_REENTRANT
test\TestAll_Of.cpp -mtune=haswell -march=x86-64 -std=c++17 -Wall -Wextra
-Werror -fno-elide-constructors -O0 -fpch-preprocess -o TestAll_Of.ii
ignoring duplicate directory
"d:/mingw17_1/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../include/c++/9.2.0"
ignoring duplicate directory
"d:/mingw17_1/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../include/c++/9.2.0/x86_64-w64-mingw32"
ignoring duplicate directory
"d:/mingw17_1/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../include/c++/9.2.0/backward"
ignoring duplicate directory
"d:/mingw17_1/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/9.2.0/include"
ignoring nonexistent directory
"C:/temp/gcc/destC:/temp/gcc/dest/lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../include"
ignoring duplicate directory
"d:/mingw17_1/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/9.2.0/include-fixed"
ignoring duplicate directory
"d:/mingw17_1/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "C:/temp/gcc/dest/mingw/include"
ignoring nonexistent directory "test\testenv"
#include "..." search starts here:
#include <...> search starts here:
 applib
 zlib
 D:\MinGW17_1\include
 D:\MinGW17_1\include\freetype2

d:\mingw17_1\bin\../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../include/c++/9.2.0

d:\mingw17_1\bin\../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../include/c++/9.2.0/x86_64-w64-mingw32

d:\mingw17_1\bin\../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../include/c++/9.2.0/backward
 d:\mingw17_1\bin\../lib/gcc/x86_64-w64-mingw32/9.2.0/include
 d:\mingw17_1\bin\../lib/gcc/x86_64-w64-mingw32/9.2.0/include-fixed

d:\mingw17_1\bin\../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'test\TestAll_Of.o' '-c' '-Wall'
'-Wextra' '-O0' '-std=c++17' '-Werror' '-coverage' '-fno-elide-constructors'
'-I' 'applib' '-I' 'zlib' '-I' 'test\testenv' '-mtune=haswell' '-march=x86-64'
 d:/mingw17_1/bin/../libexec/gcc/x86_64-w64-mingw32/9.2.0/cc1plus.exe
-fpreprocessed TestAll_Of.ii -quiet -dumpbase TestAll_Of.cpp -mtune=haswell
-march=x86-64 -auxbase-strip test\TestAll_Of.o -O0 -Wall -Wextra -Werror
-std=c++17 -version -fno-elide-constructors -fprofile-arcs -ftest-coverage -o
TestAll_Of.s
GNU C++17 (GCC) version 9.2.0 (x86_64-w64-mingw32)
        compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version
4.0.2-p1, MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++17 (GCC) version 9.2.0 (x86_64-w64-mingw32)
        compiled by GNU C version 9.2.0, GMP version 6.1.2, MPFR version
4.0.2-p1, MPC version 1.1.0, isl version isl-0.21-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 59298311a00151dbb7f6557e142e1168
In file included from d:\mingw17_1\include\c++\9.2.0\bits\stl_algobase.h:71,
                 from d:\mingw17_1\include\c++\9.2.0\vector:60,
                 from test\TestAll_Of.cpp:2:
d:\mingw17_1\include\c++\9.2.0\bits\predefined_ops.h: In instantiation of
'__gnu_cxx::__ops::_Iter_pred<_Predicate>
__gnu_cxx::__ops::__pred_iter(_Predicate) [with _Predicate =
Foo::allTargetsAreNotEmpty(const std::vector<Target>&)::<lambda(Target)>]':
d:\mingw17_1\include\c++\9.2.0\bits\stl_algo.h:567:34:   required from '_IIter
std::find_if_not(_IIter, _IIter, _Predicate) [with _IIter =
__gnu_cxx::__normal_iterator<const Target*, std::vector<Target> >; _Predicate =
Foo::allTargetsAreNotEmpty(const std::vector<Target>&)::<lambda(Target)>]'
d:\mingw17_1\include\c++\9.2.0\bits\stl_algo.h:509:40:   required from 'bool
std::all_of(_IIter, _IIter, _Predicate) [with _IIter =
__gnu_cxx::__normal_iterator<const Target*, std::vector<Target> >; _Predicate =
Foo::allTargetsAreNotEmpty(const std::vector<Target>&)::<lambda(Target)>]'
test\TestAll_Of.cpp:16:5:   required from here
d:\mingw17_1\include\c++\9.2.0\bits\predefined_ops.h:289:14: internal compiler
error: in implicitly_declare_fn, at cp/method.c:2058
  289 |     { return _Iter_pred<_Predicate>(_GLIBCXX_MOVE(__pred)); }
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libbacktrace could not find executable to open
Please submit a full bug report,
with preprocessed source if appropriate.
See <https://gcc.gnu.org/bugs/> for instructions.

#########################################
//TestAll_Of.cpp
#include <vector>
#include <algorithm>

struct Target{
    int rxd;
};
class Foo{
    int empty;
    bool allTargetsAreNotEmpty(const std::vector<Target>& targets) {
        //IsRxdEmpty e(devices);
        //return std::all_of(std::begin(targets), std::end(targets), e);

        return std::all_of(std::begin(targets), std::end(targets),
[this](Target target) {
            return target.rxd != empty;
        });
    }
};

######
I found this bug when using gcc 8.1 and switched to 9.2 to see if it had been
fixed.

The bug occurs when the lambda starts with [this] and not otherwise.

The workaround I am using is to provide a functor instead of a lambda.

Reply via email to