[Bug c++/113498] ICE in GCC trunk: tree check: have using_decl in get_template_info, at cp/pt.cc:357

2024-01-18 Thread bobmiller at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113498

--- Comment #2 from Bob Miller  ---
Apologies, I should have reduced this test case further before submission, but
I was under the mistaken impression that the template weirdness was the cause.
I believe this is a minimized example: https://godbolt.org/z/s3vGEh4Wx

template
struct S_Base
{
static constexpr int D = d;
};

template
struct S : public S_Base
{
using S_Base::D;
constexpr void f() const
requires(D > 0) {}

};

int main(int, char**)
{
S<1> s;
s.f();
return 0;
}

[Bug c++/113498] ICE in GCC trunk: tree check: have using_decl in get_template_info, at cp/pt.cc:357

2024-01-18 Thread bobmiller at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113498

--- Comment #1 from Bob Miller  ---
Bug also occurs on GCC Trunk in Compiler Explorer.
Small test case to reproduce bug: https://godbolt.org/z/TorE88bMT

#include 

template class ThisTT,
typename T,
size_t...Dims>
struct S_Base
{
static constexpr size_t D = (Dims *...);
};

template class ThisTT,
typename T,
size_t...Dims>
struct S : public S_Base
{
using S_Base::D;
constexpr ThisTT f() const
requires(D > 0) {return {};}

};

template
struct S2 : public S
{
};

int main(int, char**)
{
S2 s2;
s2.f();
return 0;
}

[Bug c++/113498] New: ICE in GCC trunk: tree check: have using_decl in get_template_info, at cp/pt.cc:357

2024-01-18 Thread bobmiller at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113498

Bug ID: 113498
   Summary: ICE in GCC trunk: tree check: have using_decl in
get_template_info, at cp/pt.cc:357
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: bobmiller at nvidia dot com
  Target Milestone: ---

Created attachment 57154
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57154=edit
GCC Bug report generated via -freport-bug

the exact version of GCC: Any GCC trunk at/after 14.0.0-20240107gita6b8d8f919c4

the system type: x86_64-pc-linux-gnu

the options given when GCC was configured/built: ../configure
--prefix=/opt/gcc-latest --enable-languages=c,c++ --enable-libstdcxx-debug
--enable-libstdcxx-backtrace --disable-bootstrap --disable-multilib
--disable-libvtv --with-system-zlib --without-isl --enable-multiarch

the complete command line that triggers the bug: ./g++ -O3 --std=c++23 -Wall
-Wextra -pedantic -freport-bug /test.cpp -o /test


the compiler output (error messages, warnings, etc.):




the preprocessed file (*.i*) that triggers the bug, generated by adding
-save-temps to the complete compilation command, or, in the case of a bug
report for the GNAT front end, a complete set of source files (see below): This
is the file attached to this bug.

root@ceceda56193b:/opt/gcc-latest/bin# ./g++ -O3 --std=c++23 -Wall -Wextra
-pedantic -freport-bug /test.cpp -o /test
/test.cpp: In instantiation of 'constexpr ThisTT S::f() const requires ('using_decl' not supported by expression) > 0 [with
ThisTT = S2; T = int; long unsigned int ...Dims = {1, 1}]':
/test.cpp:30:9:   required from here
   30 | s2.f();
  | ^~
/test.cpp:18:26: error: no return statement in 'constexpr' function returning
non-void
   18 | requires(D > 0) {}
  |  ^
/test.cpp: In instantiation of 'constexpr ThisTT S::f() const requires ('using_decl' not supported by expression) > 0 [with
ThisTT = S2; T = int; long unsigned int ...Dims = {1, 1}]':
/test.cpp:17:34: internal compiler error: tree check: expected var_decl or
function_decl or field_decl or type_decl or concept_decl or template_decl, have
using_decl in get_template_info, at cp/pt.cc:357
   17 | constexpr ThisTT f() const
  |  ^
0x7994c4 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
../../gcc/tree.cc:8954
0xafa224 template_info_decl_check(tree_node const*, char const*, int, char
const*)
../../gcc/cp/cp-tree.h:665
0xafa224 get_template_info(tree_node const*)
../../gcc/cp/pt.cc:357
0xb0455f most_general_template(tree_node const*)
../../gcc/cp/pt.cc:26017
0xa063f2 write_unqualified_name
../../gcc/cp/mangle.cc:1601
0xa12561 write_nested_name
../../gcc/cp/mangle.cc:1273
0xa13159 write_encoding
../../gcc/cp/mangle.cc:938
0xa1338b write_mangled_name
../../gcc/cp/mangle.cc:820
0xa0a00f write_expression
../../gcc/cp/mangle.cc:3441
0xa08f8e write_expression
../../gcc/cp/mangle.cc:3942
0xa1327d write_constraint_expression
../../gcc/cp/mangle.cc:860
0xa1327d write_encoding
../../gcc/cp/mangle.cc:968
0xa1338b write_mangled_name
../../gcc/cp/mangle.cc:820
0xa15138 mangle_decl_string
../../gcc/cp/mangle.cc:4420
0xa153d8 get_mangled_id
../../gcc/cp/mangle.cc:4441
0xa153d8 mangle_decl(tree_node*)
../../gcc/cp/mangle.cc:4479
0x16a2175 decl_assembler_name(tree_node*)
../../gcc/tree.cc:719
0xd947ab symtab_node::get_comdat_group_id()
../../gcc/cgraph.h:258
0xd947ab analyze_functions
../../gcc/cgraphunit.cc:1200
0xd960cd symbol_table::finalize_compilation_unit()
../../gcc/cgraphunit.cc:2555
Please submit a full bug report, with preprocessed source.
Please include the complete backtrace with any bug report.
See  for instructions.


Please let me know if additional information is required :D

[Bug c++/100279] [ICE in trunk] ICE caused by negative double NTTP. Error: Two symbols with same comdat_group are not linked by the same_comdat_group list.

2021-04-26 Thread bobmiller at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100279

--- Comment #3 from Bob Miller  ---
Further minimized example. Same ICE. 
ICE is visible here: https://godbolt.org/z/o7M9nYYYE

template struct T {};

template
void f(T) {}

int main(int, char**) 
{
f(T<-1.0>{});
f(T<-2.0>{});
return 0;
}

[Bug c++/100279] Invalid generated assembly for NTTP lambda with negative double value

2021-04-26 Thread bobmiller at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100279

--- Comment #2 from Bob Miller  ---
In further minifying this example, I've discovered a related ICE. The ICE can
be seen on godbolt here: https://godbolt.org/z/vxzG1zMjo

I've attached a new preprocessed file that triggers the ICE. Code is as
follows:

template struct T {};

template
void f(T) {}

template
void E()
{
f(T{});
f(T{});
}

void foo()
{
E<-1.0, -2.0>();
}

int main(int, char**) {return 0;}

New example's error output:

Using built-in specs.
COLLECT_GCC=/opt/compiler-explorer/gcc-snapshot/bin/g++
Target: x86_64-linux-gnu
Configured with: ../gcc-trunk-20210426/configure
--prefix=/opt/compiler-explorer/gcc-build/staging --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-bootstrap
--enable-multiarch --with-abi=m64 --with-multilib-list=m32,m64,mx32
--enable-multilib --enable-clocale=gnu --enable-languages=c,c++,fortran,ada,d
--enable-ld=yes --enable-gold=yes --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-linker-build-id --enable-lto
--enable-plugins --enable-threads=posix
--with-pkgversion=Compiler-Explorer-Build
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210425 (experimental) (Compiler-Explorer-Build) 
COLLECT_GCC_OPTIONS='-fdiagnostics-color=always' '-g' '-o' '/app/output.s'
'-masm=intel' '-S' '-std=c++20' '-v' '-save-temps' '-Wall' '-Wextra'
'-fno-strict-aliasing' '-fwrapv' '-fno-aggressive-loop-optimizations'
'-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' '/app/'

/opt/compiler-explorer/gcc-trunk-20210426/bin/../libexec/gcc/x86_64-linux-gnu/12.0.0/cc1plus
-E -quiet -v -imultiarch x86_64-linux-gnu -iprefix
/opt/compiler-explorer/gcc-trunk-20210426/bin/../lib/gcc/x86_64-linux-gnu/12.0.0/
-D_GNU_SOURCE  -masm=intel -mtune=generic -march=x86-64 -std=c++20
-Wall -Wextra -fdiagnostics-color=always -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations -g -fworking-directory -fpch-preprocess -o
/app/output.ii
ignoring nonexistent directory
"/opt/compiler-explorer/gcc-trunk-20210426/bin/../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../x86_64-linux-gnu/include"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210426/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210426/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0/x86_64-linux-gnu"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210426/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0/backward"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210426/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/12.0.0/include"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring duplicate directory
"/opt/compiler-explorer/gcc-trunk-20210426/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/12.0.0/include-fixed"
ignoring nonexistent directory
"/opt/compiler-explorer/gcc-trunk-20210426/bin/../lib/gcc/../../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/opt/compiler-explorer/gcc-trunk-20210426/bin/../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0

/opt/compiler-explorer/gcc-trunk-20210426/bin/../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0/x86_64-linux-gnu

/opt/compiler-explorer/gcc-trunk-20210426/bin/../lib/gcc/x86_64-linux-gnu/12.0.0/../../../../include/c++/12.0.0/backward

/opt/compiler-explorer/gcc-trunk-20210426/bin/../lib/gcc/x86_64-linux-gnu/12.0.0/include

/opt/compiler-explorer/gcc-trunk-20210426/bin/../lib/gcc/x86_64-linux-gnu/12.0.0/include-fixed
 /usr/local/include
 /opt/compiler-explorer/gcc-trunk-20210426/bin/../lib/gcc/../../include
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-fdiagnostics-color=always' '-g' '-o' '/app/output.s'
'-masm=intel' '-S' '-std=c++20' '-v' '-save-temps' '-Wall' '-Wextra'
'-fno-strict-aliasing' '-fwrapv' '-fno-aggressive-loop-optimizations'
'-shared-libgcc' '-mtune=generic' '-march=x86-64' '-dumpdir' '/app/'

/opt/compiler-explorer/gcc-trunk-20210426/bin/../libexec/gcc/x86_64-linux-gnu/12.0.0/cc1plus
-fpreprocessed /app/output.ii -quiet -dumpdir /app/ -dumpbase output.cpp
-dumpbase-ext .cpp -masm=intel -mtune=generic -march=x86-64 -g -Wall -Wextra
-std=c++20 -version -fdiagnostics-color=always -fno-strict-aliasing -fwrapv
-fno-aggressive-loop-optimizations -o /app/output.s
GNU C++20 (Compiler-Explorer-Build) version 12.0.0 20210425 (experimental)
(x86_64-linux-gnu)
compiled by GNU C version 7.5.0, GMP version 6.1.0, MPFR version 3.1.4,
MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C++20 (Compiler-Explorer-Build) version 12.0.0 20210425 (experimental)
(x86_64-linux-gnu)
 

[Bug c++/100279] Invalid generated assembly for NTTP lambda with negative double value

2021-04-26 Thread bobmiller at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100279

--- Comment #1 from Bob Miller  ---
Created attachment 50684
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50684=edit
New preprocessed source for more minimal example. This one leads to an ICE on
godbolt's GCC version.

[Bug c++/100279] New: Invalid generated assembly for NTTP lambda with negative double value

2021-04-26 Thread bobmiller at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100279

Bug ID: 100279
   Summary: Invalid generated assembly for NTTP lambda with
negative double value
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: bobmiller at nvidia dot com
  Target Milestone: ---

Created attachment 50683
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50683=edit
The preprocessed file that triggers the bug

I've stumbled across an obscure behavior that results in incorrect assembly
generation: the same signature is generated twice, which the assembler later
(correctly) rejects. I've tested this on GCC-11 and trunk, on my own machine
and godbolt ( example here: https://godbolt.org/z/6eEnKca9o )

Minimal example: 

template struct T {};

template void E(F &&) {}

template
void E(F &)
{
f(T{});
E(f);
}

void foo()
{
E<-1.0, -2.0>(
[&](T){});
}

int main(int, char**) {}
--

Interestingly, this does NOT occur for floats or long doubles: only doubles:
changing the suffixes of -1.0 and -2.0 above to -1.0f and -2.0f (or -1.0L and
-2.0L) results in valid generated code.

--
Output from gcc -v:

COLLECT_GCC=g++-11
COLLECT_LTO_WRAPPER=/home/bob/libexec/gcc/x86_64-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../gcc/configure -v --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/home/bob/
--enable-checking=release --enable-languages=c,c++ --disable-multilib
--program-suffix=-11
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210426 (experimental) (GCC) 


Command line to trigger bug: g++-11 --std=c++20 bugtest.cpp -o test

Compiler output:
/tmp/ccmrd0Wr.s: Assembler messages:
/tmp/ccmrd0Wr.s:106: Error: symbol
`_ZZ3foovENKUl1TIXT_EEE_clILdEEEDaS0_' is already defined

[Bug c++/99132] ICE in C++20 mode for constexpr not_null evaluation -- in cxx_eval_indirect_ref, at cp/constexpr.c:4905

2021-02-17 Thread bobmiller at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99132

--- Comment #2 from Bob Miller  ---
I have reported this bug to the gsl-lite maintainer as well here:
https://github.com/gsl-lite/gsl-lite/issues/281

[Bug c++/99132] ICE in C++20 mode for constexpr not_null evaluation -- in cxx_eval_indirect_ref, at cp/constexpr.c:4905

2021-02-17 Thread bobmiller at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99132

--- Comment #1 from Bob Miller  ---
Created attachment 50211
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50211=edit
preprocessed file that triggers the bug

[Bug c++/99132] New: ICE in C++20 mode for constexpr not_null evaluation -- in cxx_eval_indirect_ref, at cp/constexpr.c:4905

2021-02-17 Thread bobmiller at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99132

Bug ID: 99132
   Summary: ICE in C++20 mode for constexpr not_null evaluation
--  in cxx_eval_indirect_ref, at cp/constexpr.c:4905
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: bobmiller at nvidia dot com
  Target Milestone: ---

Usage of gsl-lite::not_null can cause an internal compiler error.

Minimal online example: https://godbolt.org/z/Y8n93K
I also intend to report this to the gsl-lite maintainer, but I don't believe
their code should trigger an ICE regardless.

My system is x86-linux-amd64.

I confirmed in current trunk, commit hash
24bf79f1798ad1d64812709001d2d11cd3e6849f

The attached preprocessed output (a-test.ii) was built with the following
command:
g++-11 -v -save-temps --std=c++20 test.cpp

Full output:
--
Using built-in specs.
COLLECT_GCC=/home/bob/bin/g++-11
COLLECT_LTO_WRAPPER=/home/bob/libexec/gcc/x86_64-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../gcc/configure -v --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu --prefix=/home/bob/
--enable-checking=release --enable-languages=c,c++ --disable-multilib
--program-suffix=-11
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20210217 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-shared-libgcc'
'-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
 /home/bob/libexec/gcc/x86_64-linux-gnu/11.0.0/cc1plus -E -quiet -v -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE /home/bob/test.cpp -mtune=generic -march=x86-64
-std=c++20 -fpch-preprocess -o a-test.ii
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/home/bob/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/bob/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0

/home/bob/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0/x86_64-linux-gnu

/home/bob/lib/gcc/x86_64-linux-gnu/11.0.0/../../../../include/c++/11.0.0/backward
 /home/bob/lib/gcc/x86_64-linux-gnu/11.0.0/include
 /usr/local/include
 /home/bob/include
 /home/bob/lib/gcc/x86_64-linux-gnu/11.0.0/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++20' '-shared-libgcc'
'-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
 /home/bob/libexec/gcc/x86_64-linux-gnu/11.0.0/cc1plus -fpreprocessed a-test.ii
-quiet -dumpdir a- -dumpbase test.cpp -dumpbase-ext .cpp -mtune=generic
-march=x86-64 -std=c++20 -version -o a-test.s
GNU C++20 (GCC) version 11.0.0 20210217 (experimental) (x86_64-linux-gnu)
compiled by GNU C version 11.0.0 20210216 (experimental), GMP version
6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++20 (GCC) version 11.0.0 20210217 (experimental) (x86_64-linux-gnu)
compiled by GNU C version 11.0.0 20210216 (experimental), GMP version
6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4db0a130394a49defb276090de10ab74
/home/bob/test.cpp: In member function ‘virtual void
Source::attachSink(gsl::not_null)’:
/home/bob/test.cpp:15:13:   in ‘constexpr’ expansion of
‘sink.gsl::not_null::operator->()’
/home/bob/test.cpp:16:5: internal compionline example:
https://godbolt.org/z/Y8n93K
ler error: in cxx_eval_indirect_ref, at cp/constexpr.c:4905
   16 | }
  | ^
0x6649a2 cxx_eval_indirect_ref
../../gcc/gcc/cp/constexpr.c:4905
0x6649a2 cxx_eval_constant_expression
../../gcc/gcc/cp/constexpr.c:6362
0x6dfc1a cxx_eval_component_reference
../../gcc/gcc/cp/constexpr.c:3797
0x6dfc1a cxx_eval_constant_expression
../../gcc/gcc/cp/constexpr.c:6538
0x6dfc1a cxx_eval_component_reference
../../gcc/gcc/cp/constexpr.c:3797
0x6dfc1a cxx_eval_constant_expression
../../gcc/gcc/cp/constexpr.c:6538
0x6dfa23 cxx_eval_constant_expression
../../gcc/gcc/cp/constexpr.c:6634
0x6e8875 cxx_eval_binary_expression
../../gcc/gcc/cp/constexpr.c:3122
0x6df609 cxx_eval_constant_expression
../../gcc/gcc/cp/constexpr.c:6500
0x6e1889 cxx_eval_conditional_expression
../../gcc/gcc/cp/constexpr.c:3232
0x6e1889 cxx_eval_constant_expression
../../gcc/gcc/cp/constexpr.c:6581
0x6e04e0 cxx_eval_constant_expression
../../gcc/gcc/cp/constexpr.c:6309
0x6e003c cxx_eval_constant_expression
../../gcc/gcc/cp/constexpr.c:6320
0x6e0c26 cxx_eval_statement_list