[Bug c++/99200] __PRETTY_FUNCTION__ used as template parameter causes internal compiler error (segmentation fault)

2021-05-01 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99200

Patrick Palka  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 CC||ppalka at gcc dot gnu.org
   Target Milestone|--- |11.2
 Status|NEW |RESOLVED

--- Comment #9 from Patrick Palka  ---
Fixed for GCC 11.2 and 12.

[Bug c++/99200] __PRETTY_FUNCTION__ used as template parameter causes internal compiler error (segmentation fault)

2021-04-27 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99200

--- Comment #8 from CVS Commits  ---
The releases/gcc-11 branch has been updated by Patrick Palka
:

https://gcc.gnu.org/g:9532344edcf77c7c7b0fa5da31c1b9dd2850288e

commit r11-8309-g9532344edcf77c7c7b0fa5da31c1b9dd2850288e
Author: Patrick Palka 
Date:   Sat Apr 24 00:14:29 2021 -0400

c++: do_class_deduction and dependent init [PR93383]

Here we're crashing during CTAD with a dependent initializer (performed
from convert_template_argument) because one of the initializer's
elements has an empty TREE_TYPE, which ends up making resolve_args
unhappy.

Besides the case where we're initializing one template placeholder
from another, which is already specifically handled earlier in
do_class_deduction, it seems we can't in general correctly resolve a
template placeholder using a dependent initializer, so this patch makes
the function just punt until instantiation time instead.

gcc/cp/ChangeLog:

PR c++/89565
PR c++/93383
PR c++/95291
PR c++/99200
PR c++/99683
* pt.c (do_class_deduction): Punt if the initializer is
type-dependent.

gcc/testsuite/ChangeLog:

PR c++/89565
PR c++/93383
PR c++/95291
PR c++/99200
PR c++/99683
* g++.dg/cpp2a/nontype-class39.C: Remove dg-ice directive.
* g++.dg/cpp2a/nontype-class45.C: New test.
* g++.dg/cpp2a/nontype-class46.C: New test.
* g++.dg/cpp2a/nontype-class47.C: New test.
* g++.dg/cpp2a/nontype-class48.C: New test.

(cherry picked from commit bcd77b7b9f35bd5b559ed593c3b3e346c1e6f364)

[Bug c++/99200] __PRETTY_FUNCTION__ used as template parameter causes internal compiler error (segmentation fault)

2021-04-23 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99200

--- Comment #7 from CVS Commits  ---
The master branch has been updated by Patrick Palka :

https://gcc.gnu.org/g:bcd77b7b9f35bd5b559ed593c3b3e346c1e6f364

commit r12-100-gbcd77b7b9f35bd5b559ed593c3b3e346c1e6f364
Author: Patrick Palka 
Date:   Sat Apr 24 00:14:29 2021 -0400

c++: do_class_deduction and dependent init [PR93383]

Here we're crashing during CTAD with a dependent initializer (performed
from convert_template_argument) because one of the initializer's
elements has an empty TREE_TYPE, which ends up making resolve_args
unhappy.

Besides the case where we're initializing one template placeholder
from another, which is already specifically handled earlier in
do_class_deduction, it seems we can't in general correctly resolve a
template placeholder using a dependent initializer, so this patch makes
the function just punt until instantiation time instead.

gcc/cp/ChangeLog:

PR c++/89565
PR c++/93383
PR c++/95291
PR c++/99200
PR c++/99683
* pt.c (do_class_deduction): Punt if the initializer is
type-dependent.

gcc/testsuite/ChangeLog:

PR c++/89565
PR c++/93383
PR c++/95291
PR c++/99200
PR c++/99683
* g++.dg/cpp2a/nontype-class39.C: Remove dg-ice directive.
* g++.dg/cpp2a/nontype-class45.C: New test.
* g++.dg/cpp2a/nontype-class46.C: New test.
* g++.dg/cpp2a/nontype-class47.C: New test.
* g++.dg/cpp2a/nontype-class48.C: New test.

[Bug c++/99200] __PRETTY_FUNCTION__ used as template parameter causes internal compiler error (segmentation fault)

2021-03-03 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99200

--- Comment #6 from Marek Polacek  ---
(In reply to JoaoBapt from comment #4)
> (In reply to Marek Polacek from comment #2)
> > Looks like a dup of 93383.
> 
> No, because it works perfectly when I substitute __PRETTY_FUNCTION__ for any
> other string literal

That doesn't really matter; the ICE is very much like the one I described in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93383#c3, only this time we don't
have a COMPONENT_REF that is type-less, it's an identifier_node.  Therefore I
suspect the fix ought to handle both issues.

[Bug c++/99200] __PRETTY_FUNCTION__ used as template parameter causes internal compiler error (segmentation fault)

2021-02-23 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99200

--- Comment #5 from Jonathan Wakely  ---
(In reply to JoaoBapt from comment #0)
> Trying to use the macro __PRETTY_FUNCTION__ as a string-literal converted

N.B.

"These identifiers are variables, not preprocessor macros"

See https://gcc.gnu.org/onlinedocs/gcc/Function-Names.html

[Bug c++/99200] __PRETTY_FUNCTION__ used as template parameter causes internal compiler error (segmentation fault)

2021-02-22 Thread jbaptistapsilva at yahoo dot com.br via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99200

--- Comment #4 from JoaoBapt  ---
(In reply to Marek Polacek from comment #2)
> Looks like a dup of 93383.

No, because it works perfectly when I substitute __PRETTY_FUNCTION__ for any
other string literal, even as big as one that would be "returned" by
__PRETTY_FUNCTION__ (I tested with, for example, "consteval const char*
type_name() [with T = double]" and it did not crash and worked perfectly).

[Bug c++/99200] __PRETTY_FUNCTION__ used as template parameter causes internal compiler error (segmentation fault)

2021-02-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99200

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek  ---
Slightly reduced:

template 
struct A
{
  constexpr A (const char ()[N]) { for (int i = 0; i < N; i++) v[i] = s[i];
v[N] = 0; }
  char v[N + 1];
};

template 
struct B
{
  constexpr operator const char *() { return s.v; }
};

template 
const char *
foo ()
{ 
  return B<__PRETTY_FUNCTION__>{};
}

template 
const char *
bar ()
{ 
  return B<__FUNCTION__>{};
}

int
main ()
{
  auto a = foo  ();
  auto b = bar  ();
}

[Bug c++/99200] __PRETTY_FUNCTION__ used as template parameter causes internal compiler error (segmentation fault)

2021-02-22 Thread mpolacek at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99200

Marek Polacek  changed:

   What|Removed |Added

   Last reconfirmed||2021-02-22
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=93383
 Status|UNCONFIRMED |NEW
 CC||mpolacek at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #2 from Marek Polacek  ---
Looks like a dup of 93383.

[Bug c++/99200] __PRETTY_FUNCTION__ used as template parameter causes internal compiler error (segmentation fault)

2021-02-22 Thread jbaptistapsilva at yahoo dot com.br via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99200

--- Comment #1 from JoaoBapt  ---
I created a Godbolt snippet which also shows that the bug is still there in GCC
11. The entire output (but the .ii) is there on the command line:
https://godbolt.org/z/njMM3f