[Bug c++/102547] [11/12 Regression] g++ 11. ICE with NTTPs and partial specialization

2021-09-30 Thread bob.steagall.cpp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102547

--- Comment #4 from Bob Steagall  ---
I have applied this tentative change to line 23436 of gcc/cp/pt.c from the
gcc-11.2.0 source tarball, and can confirm that the test case compiles for me.

The code I was working on also compiles, links, and appears to run correctly.

I don't know if this is the final fix, but it is progress.

[Bug c++/102547] New: g++ 11. ICE with NTTPs and partial specialization

2021-09-30 Thread bob.steagall.cpp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102547

Bug ID: 102547
   Summary: g++ 11. ICE with NTTPs and partial specialization
   Product: gcc
   Version: 11.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: bob.steagall.cpp at gmail dot com
  Target Milestone: ---

The following C++ source code:

---

template
struct vals {};


template
struct vals_client {};

template
struct vals_client, A> {};

template
struct vals_client, void> {};


void testfn()
{
vals_client, int>   ci;  //- OK
vals_client, void>  cv;  //- "sorry, unimplemented..., ICE" 
}

---

When compiled with gcc 11.X generates this error:


nttp_test.cpp: In function 'void testfn()':
nttp_test.cpp:18:36: sorry, unimplemented: unexpected AST of kind
nontype_argument_pack
   18 | vals_client, void>  cv;  //- "sorry, unimplemented..."
  |^~
nttp_test.cpp:18: confused by earlier errors, bailing out

---

When compiled with gcc trunk on godbolt.org, it elicits an ICE:

: In function 'void testfn()':
:23:36: sorry, unimplemented: unexpected AST of kind
nontype_argument_pack
   23 | vals_client, void>  cv;  //- "sorry, unimplemented...,
ICE"
  |^~
:23:36: internal compiler error: in potential_constant_expression_1, at
cp/constexpr.c:9051
0x1fe73f9 internal_error(char const*, ...)
???:0
0x7d40a7 fancy_abort(char const*, int, char const*)
???:0
0x8475ff potential_constant_expression(tree_node*)
???:0
0xa21bd7 instantiation_dependent_expression_p(tree_node*)
???:0
0xa21c46 uses_template_parms(tree_node*)
???:0
0xa72888 most_specialized_partial_spec(tree_node*, int)
???:0
0xa7f834 instantiate_class_template(tree_node*)
???:0
0x89e107 start_decl_1(tree_node*, bool)
???:0
0x8c552f start_decl(cp_declarator const*, cp_decl_specifier_seq*, int,
tree_node*, tree_node*, tree_node**)
???:0
0xa08395 c_parse_file()
???:0
0xb8f562 c_common_parse_file()
???:0
Please submit a full bug report, ...

---

Testing with various version on godbolt.org reveals that the ICE does not 
occur with 10.X, 9.X, 8.X, or 7.X  (that's as far back as I went).

[Bug libstdc++/88374] crash when stepping into for loop where iterators are created and compared with gdb

2018-12-06 Thread bob.steagall.cpp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88374

--- Comment #2 from Bob Steagall  ---
See https://sourceware.org/bugzilla/show_bug.cgi?id=20020, especially comment 7
for more data.

[Bug libstdc++/88374] crash when stepping into for loop where iterators are created and compared with gdb

2018-12-06 Thread bob.steagall.cpp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88374

--- Comment #1 from Bob Steagall  ---
See https://sourceware.org/bugzilla/show_bug.cgi?id=23953 for the report made
to the gdb team, including stack traces and a link to the gdb executable and
the core file generated when it SEGVs.

[Bug c++/88374] New: crash when stepping into for loop where iterators are created and compared with gdb

2018-12-05 Thread bob.steagall.cpp at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88374

Bug ID: 88374
   Summary: crash when stepping into for loop where iterators are
created and compared with gdb
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: bob.steagall.cpp at gmail dot com
  Target Milestone: ---

Created attachment 45161
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45161=edit
preprocessed source file to demonstrate problem

Consider the following code:


#include 
#include 

struct TS
{
std::atomic mPtr;
};

int main()
{
std::vector test(10);
volatile inti = 0;

for (auto iter = test.begin();  iter != test.end();  ++iter)
{
++i;
}
return 0;
}


GDB 7.11 and 8.2 both crash when repeatedly stepping into the for loop on line
14 when compiled with gcc 8.2 and -std=c++17.

The problem appears to be related to the combination of std::atomic as an
element type AND the compilation flag -std=c++17.

If I change the flag to -std=c++14, gdb does not crash, and I can step thru the
iterator instantiations and comparisons as expected.  Also, if I change the
pointer type to void*, the crash does not occur, and stepping works correctly.  

I'm not sure if this is a GDB problem or a g++ codegen problem (or both?), so
I'm filing this report with both products.

Thanks,
--Bob


To reproduce:

$ g++ -std=c++17 -Wall -Wextra -g -O0 test_dbg.cpp -o test_dbg
$ gdb test_dbg

inside of gdb:

(gdb) b 12
(gdb) r
(gdb) s
(gdb) s
(gdb) s
(gdb) s
(gdb) s
(gdb) s
 { gdb crashes with segv }


The following is a transcript from such a session:

Reading symbols from test_dbg...done.
(gdb) b 12
Breakpoint 1 at 0x400738: file test_dbg.cpp, line 12.
(gdb) r
Starting program: /space/tmp/test_dbg

Breakpoint 1, main () at test_dbg.cpp:12
(gdb) s
(gdb) s
std::vector >::begin (this=0x7fffd7a0)
at /usr/local/gcc/8.2.0/include/c++/8.2.0/bits/stl_vector.h:699
(gdb) s
__gnu_cxx::__normal_iterator >
>::__normal_iterator (
this=0x7fffd778, __i=@0x7fffd7a0: 0x614c20)
at /usr/local/gcc/8.2.0/include/c++/8.2.0/bits/stl_iterator.h:781
(gdb) s
std::vector >::end (this=0x7fffd7a0)
at /usr/local/gcc/8.2.0/include/c++/8.2.0/bits/stl_vector.h:717
(gdb) s
__gnu_cxx::__normal_iterator >
>::__normal_iterator (
this=0x7fffd778, __i=@0x7fffd7a8: 0x614c70)
at /usr/local/gcc/8.2.0/include/c++/8.2.0/bits/stl_iterator.h:781
(gdb) s
Segmentation fault (core dumped)

=
Here are the tool specs:

$ gdb -v
GNU gdb (GDB) 8.2
Copyright (C) 2018 Free Software Foundation, Inc. ...


$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:Ubuntu 16.04.5 LTS
Release:16.04
Codename:   xenia


$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/gcc/8.2.0/libexec/gcc/x86_64-kewb-linux-gnu/8.2.0/lto-wrapper
Target: x86_64-kewb-linux-gnu
Configured with: /space/zbuild/gcc-builder/gcc-8.2.0/configure -v
--with-pkgversion='KEWB Computing Build' --prefix=/usr/local/gcc/8.2.0
--program-suffix= --enable-tls --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++
--enable-lto --enable-bootstrap --disable-nls --disable-multilib
--disable-install-libiberty --disable-werror --with-system-zlib
Thread model: posix
gcc version 8.2.0 (KEWB Computing Build) 

$ g++ -v -save-temps -std=c++17 -Wall -Wextra -g -O0 test_dbg.cpp -o test_dbg
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/gcc/8.2.0/libexec/gcc/x86_64-kewb-linux-gnu/8.2.0/lto-wrapper
Target: x86_64-kewb-linux-gnu
Configured with: /space/zbuild/gcc-builder/gcc-8.2.0/configure -v
--with-pkgversion='KEWB Computing Build' --prefix=/usr/local/gcc/8.2.0
--program-suffix= --enable-tls --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++
--enable-lto --enable-bootstrap --disable-nls --disable-multilib
--disable-install-libiberty --disable-werror --with-system-zlib
Thread model: posix
gcc version 8.2.0 (KEWB Computing Build) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++17' '-Wall' '-Wextra' '-g'
'-O0' '-o' 'test_dbg' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/local/gcc/8.2.0/libexec/gcc/x86_64-kewb-linux-gnu/8.2.0/cc1plus -E -quiet
-v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE test_dbg.cpp -mtune=generic
-march=x86-64 -std=c++17 -Wall -Wextra -g -fworking-directory -O0
-fpch-preprocess -o test_dbg.ii
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/local/gcc/8.2.0/lib/gcc/x86_64-kewb-linux-gnu/8.2.0/../../../../x86_64-kewb-linux-gnu/include"
#include "...&quo