public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105779] New: internal_error on passing a pointer to static function to another function
@ 2022-05-30 21:37 bart at bartjanssens dot org
  2022-05-30 21:45 ` [Bug c++/105779] [12 Regression] " pinskia at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: bart at bartjanssens dot org @ 2022-05-30 21:37 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105779
           Summary: internal_error on passing a pointer to static function
                    to another function
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bart at bartjanssens dot org
  Target Milestone: ---

Created attachment 53054
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53054&action=edit
Minimal example to reproduce this

Compiling the attached test case fails, explicitly adding & on line 23 to
indicate that method takes a pointer to a function solves the problem, but I
believe both should compile (and did prior to GCC 12), and certainly not crash.

Compile command: g++ -Wall -Wextra test-pointer.cpp
Output:
during RTL pass: expand
test-pointer.cpp: In member function ‘int
WrapSmartPointer::operator()(TypeWrapperT&&) [with TypeWrapperT = IntWrapper]’:
test-pointer.cpp:23:18: internal compiler error: Segmentation fault
   23 |     return method(DereferenceSmartPointer<WrappedT>::apply); //
method(&DereferenceSmartPointer<WrappedT>::apply) works
      |            ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0x1ac4724 internal_error(char const*, ...)
        ???:0
0x11072d7 make_decl_rtl(tree_node*)
        ???:0
0x95ad77 expand_call(tree_node*, rtx_def*, int)
        ???:0
0xab27af expand_expr_real_1(tree_node*, rtx_def*, machine_mode,
expand_modifier, rtx_def**, bool)
        ???:0
0xa930b4 store_expr(tree_node*, rtx_def*, int, bool, bool)
        ???:0
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.archlinux.org/> for instructions.

GCC version: g++ (GCC) 12.1.0 (Arch Linux package)
System: Linux 5.15.43-1-lts #1 SMP Wed, 25 May 2022 14:08:34 +0000 x86_64
GNU/Linux

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/105779] [12 Regression] internal_error on passing a pointer to static function to another function
  2022-05-30 21:37 [Bug c++/105779] New: internal_error on passing a pointer to static function to another function bart at bartjanssens dot org
@ 2022-05-30 21:45 ` pinskia at gcc dot gnu.org
  2022-05-30 23:52 ` pinskia at gcc dot gnu.org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-30 21:45 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |12.1.0
      Known to work|                            |11.3.0, 13.0
   Target Milestone|---                         |12.2
   Last reconfirmed|                            |2022-05-30
           Keywords|                            |ice-on-valid-code
            Summary|internal_error on passing a |[12 Regression]
                   |pointer to static function  |internal_error on passing a
                   |to another function         |pointer to static function
                   |                            |to another function
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is interesting as it works on the trunk ...

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/105779] [12 Regression] internal_error on passing a pointer to static function to another function
  2022-05-30 21:37 [Bug c++/105779] New: internal_error on passing a pointer to static function to another function bart at bartjanssens dot org
  2022-05-30 21:45 ` [Bug c++/105779] [12 Regression] " pinskia at gcc dot gnu.org
@ 2022-05-30 23:52 ` pinskia at gcc dot gnu.org
  2022-05-31  5:01 ` [Bug c++/105779] [12/13 Regression] static function with auto return type not being resolved correctly pinskia at gcc dot gnu.org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-30 23:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
    using WrappedT = typename TypeWrapperT::type;

is important ...

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/105779] [12/13 Regression] static function with auto return type not being resolved correctly
  2022-05-30 21:37 [Bug c++/105779] New: internal_error on passing a pointer to static function to another function bart at bartjanssens dot org
  2022-05-30 21:45 ` [Bug c++/105779] [12 Regression] " pinskia at gcc dot gnu.org
  2022-05-30 23:52 ` pinskia at gcc dot gnu.org
@ 2022-05-31  5:01 ` pinskia at gcc dot gnu.org
  2022-05-31  5:02 ` pinskia at gcc dot gnu.org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-31  5:01 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
            Summary|[12 Regression]             |[12/13 Regression] static
                   |internal_error on passing a |function with auto return
                   |pointer to static function  |type not being resolved
                   |to another function         |correctly

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is a even more reduced testcase which is rejected rather than crashes. It
is also is rejected on the trunk:
template<int>
struct struct1
{
  static auto apply()
  {
    return 1;
  }
};

int method(int(*f)());

int t = method(struct1<1>::apply);

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/105779] [12/13 Regression] static function with auto return type not being resolved correctly
  2022-05-30 21:37 [Bug c++/105779] New: internal_error on passing a pointer to static function to another function bart at bartjanssens dot org
                   ` (2 preceding siblings ...)
  2022-05-31  5:01 ` [Bug c++/105779] [12/13 Regression] static function with auto return type not being resolved correctly pinskia at gcc dot gnu.org
@ 2022-05-31  5:02 ` pinskia at gcc dot gnu.org
  2022-05-31  5:03 ` pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-31  5:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> Here is a even more reduced testcase which is rejected rather than crashes.
> It is also is rejected on the trunk:
> template<int>
> struct struct1
> {
>   static auto apply()
>   {
>     return 1;
>   }
> };
> 
> int method(int(*f)());
> 
> int t = method(struct1<1>::apply);

Note if you want to reproduce the crash, just change method to:
template<class T>
int method(T(*f)());

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/105779] [12/13 Regression] static function with auto return type not being resolved correctly
  2022-05-30 21:37 [Bug c++/105779] New: internal_error on passing a pointer to static function to another function bart at bartjanssens dot org
                   ` (3 preceding siblings ...)
  2022-05-31  5:02 ` pinskia at gcc dot gnu.org
@ 2022-05-31  5:03 ` pinskia at gcc dot gnu.org
  2022-05-31 13:20 ` mpolacek at gcc dot gnu.org
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-05-31  5:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> Here is a even more reduced testcase which is rejected rather than crashes.
> It is also is rejected on the trunk:

Here is the error message for the rejection (which does not even make sense
since to the eye, the type looks exactly the same):
<source>:13:15: error: invalid conversion from 'int (*)()' to 'int (*)()'
[-fpermissive]
   13 | int t = method(struct1<1>::apply);
      |         ~~~~~~^~~~~~~~~~~~~~~~~~~
      |               |
      |               int (*)()
<source>:11:17: note:   initializing argument 1 of 'int method(int (*)())'
   11 | int method(int(*f)());
      |            ~~~~~^~~~

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/105779] [12/13 Regression] static function with auto return type not being resolved correctly
  2022-05-30 21:37 [Bug c++/105779] New: internal_error on passing a pointer to static function to another function bart at bartjanssens dot org
                   ` (4 preceding siblings ...)
  2022-05-31  5:03 ` pinskia at gcc dot gnu.org
@ 2022-05-31 13:20 ` mpolacek at gcc dot gnu.org
  2022-05-31 13:20 ` mpolacek at gcc dot gnu.org
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-05-31 13:20 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|needs-bisection             |
                 CC|                            |jason at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org

--- Comment #6 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r12-1270-ga1b3484a8e6c53 (both Comment 3 and Comment 4)

commit a1b3484a8e6c53c8084723e3f1738d402374198e
Author: Jason Merrill <jason@redhat.com>
Date:   Mon May 31 12:56:34 2021 -0400

    c++: alias member template [PR100102]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/105779] [12/13 Regression] static function with auto return type not being resolved correctly
  2022-05-30 21:37 [Bug c++/105779] New: internal_error on passing a pointer to static function to another function bart at bartjanssens dot org
                   ` (5 preceding siblings ...)
  2022-05-31 13:20 ` mpolacek at gcc dot gnu.org
@ 2022-05-31 13:20 ` mpolacek at gcc dot gnu.org
  2022-05-31 19:35 ` jason at gcc dot gnu.org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2022-05-31 13:20 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/105779] [12/13 Regression] static function with auto return type not being resolved correctly
  2022-05-30 21:37 [Bug c++/105779] New: internal_error on passing a pointer to static function to another function bart at bartjanssens dot org
                   ` (6 preceding siblings ...)
  2022-05-31 13:20 ` mpolacek at gcc dot gnu.org
@ 2022-05-31 19:35 ` jason at gcc dot gnu.org
  2022-06-01 19:21 ` cvs-commit at gcc dot gnu.org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2022-05-31 19:35 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/105779] [12/13 Regression] static function with auto return type not being resolved correctly
  2022-05-30 21:37 [Bug c++/105779] New: internal_error on passing a pointer to static function to another function bart at bartjanssens dot org
                   ` (7 preceding siblings ...)
  2022-05-31 19:35 ` jason at gcc dot gnu.org
@ 2022-06-01 19:21 ` cvs-commit at gcc dot gnu.org
  2022-06-01 19:53 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-01 19:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

https://gcc.gnu.org/g:72e52b88582e738c8b8bde5f85af63d3a0e15d2b

commit r13-919-g72e52b88582e738c8b8bde5f85af63d3a0e15d2b
Author: Jason Merrill <jason@redhat.com>
Date:   Tue May 31 16:17:58 2022 -0400

    c++: auto function as function argument [PR105779]

    This testcase demonstrates that the issue in PR105623 is not limited to
    templates, so we should do the marking in a less template-specific place.

            PR c++/105779

    gcc/cp/ChangeLog:

            * call.cc (resolve_args): Call mark_single_function here.
            * pt.cc (unify_one_argument): Not here.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/auto-fn63.C: New test.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/105779] [12/13 Regression] static function with auto return type not being resolved correctly
  2022-05-30 21:37 [Bug c++/105779] New: internal_error on passing a pointer to static function to another function bart at bartjanssens dot org
                   ` (8 preceding siblings ...)
  2022-06-01 19:21 ` cvs-commit at gcc dot gnu.org
@ 2022-06-01 19:53 ` cvs-commit at gcc dot gnu.org
  2022-06-01 19:54 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-01 19:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

https://gcc.gnu.org/g:819e3fda1e0fc4cc07f5fd9211cdb38cdec1b901

commit r12-8446-g819e3fda1e0fc4cc07f5fd9211cdb38cdec1b901
Author: Jason Merrill <jason@redhat.com>
Date:   Tue May 31 16:17:58 2022 -0400

    c++: auto function as function argument [PR105779]

    This testcase demonstrates that the issue in PR105623 is not limited to
    templates, so we should do the marking in a less template-specific place.

            PR c++/105779

    gcc/cp/ChangeLog:

            * call.cc (resolve_args): Call mark_single_function here.
            * pt.cc (unify_one_argument): Not here.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp1y/auto-fn63.C: New test.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/105779] [12/13 Regression] static function with auto return type not being resolved correctly
  2022-05-30 21:37 [Bug c++/105779] New: internal_error on passing a pointer to static function to another function bart at bartjanssens dot org
                   ` (9 preceding siblings ...)
  2022-06-01 19:53 ` cvs-commit at gcc dot gnu.org
@ 2022-06-01 19:54 ` jason at gcc dot gnu.org
  2022-07-01 14:55 ` cvs-commit at gcc dot gnu.org
  2022-07-01 14:55 ` cvs-commit at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: jason at gcc dot gnu.org @ 2022-06-01 19:54 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for 12.2/13.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/105779] [12/13 Regression] static function with auto return type not being resolved correctly
  2022-05-30 21:37 [Bug c++/105779] New: internal_error on passing a pointer to static function to another function bart at bartjanssens dot org
                   ` (10 preceding siblings ...)
  2022-06-01 19:54 ` jason at gcc dot gnu.org
@ 2022-07-01 14:55 ` cvs-commit at gcc dot gnu.org
  2022-07-01 14:55 ` cvs-commit at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-01 14:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jason Merrill <jason@gcc.gnu.org>:

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

commit r13-1392-gaefe23f720a542e90ecc6629885b01d44139b043
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jul 1 00:37:10 2022 -0400

    c++: tweak resolve_args change

    I don't know why I used tf_error instead of complain here.

            PR c++/105779

    gcc/cp/ChangeLog:

            * call.cc (resolve_args): Use complain.

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug c++/105779] [12/13 Regression] static function with auto return type not being resolved correctly
  2022-05-30 21:37 [Bug c++/105779] New: internal_error on passing a pointer to static function to another function bart at bartjanssens dot org
                   ` (11 preceding siblings ...)
  2022-07-01 14:55 ` cvs-commit at gcc dot gnu.org
@ 2022-07-01 14:55 ` cvs-commit at gcc dot gnu.org
  12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-01 14:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-12 branch has been updated by Jason Merrill
<jason@gcc.gnu.org>:

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

commit r12-8534-gd9130880f77c7f9ffd5deaabda605bc151521be5
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jul 1 00:37:10 2022 -0400

    c++: tweak resolve_args change

    I don't know why I used tf_error instead of complain here.

            PR c++/105779

    gcc/cp/ChangeLog:

            * call.cc (resolve_args): Use complain.

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-07-01 14:55 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-30 21:37 [Bug c++/105779] New: internal_error on passing a pointer to static function to another function bart at bartjanssens dot org
2022-05-30 21:45 ` [Bug c++/105779] [12 Regression] " pinskia at gcc dot gnu.org
2022-05-30 23:52 ` pinskia at gcc dot gnu.org
2022-05-31  5:01 ` [Bug c++/105779] [12/13 Regression] static function with auto return type not being resolved correctly pinskia at gcc dot gnu.org
2022-05-31  5:02 ` pinskia at gcc dot gnu.org
2022-05-31  5:03 ` pinskia at gcc dot gnu.org
2022-05-31 13:20 ` mpolacek at gcc dot gnu.org
2022-05-31 13:20 ` mpolacek at gcc dot gnu.org
2022-05-31 19:35 ` jason at gcc dot gnu.org
2022-06-01 19:21 ` cvs-commit at gcc dot gnu.org
2022-06-01 19:53 ` cvs-commit at gcc dot gnu.org
2022-06-01 19:54 ` jason at gcc dot gnu.org
2022-07-01 14:55 ` cvs-commit at gcc dot gnu.org
2022-07-01 14:55 ` cvs-commit at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).