public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115364] New: ICE-on-invalid when calling non-const template member on const object
@ 2024-06-05 18:16 blubban at gmail dot com
  2024-06-05 18:39 ` [Bug c++/115364] [11/12/13/14/15 Regression] " pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: blubban at gmail dot com @ 2024-06-05 18:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115364
           Summary: ICE-on-invalid when calling non-const template member
                    on const object
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: blubban at gmail dot com
  Target Milestone: ---

struct foo
{
    template<int> void not_const() {}
};
void fn(const foo& obj) { obj.not_const<5>(); }


No flags needed.


<source>: In member function 'void foo::fn() const':
<source>:4:41: error: cannot convert 'const foo*' to 'foo*'
    4 |     void fn() const { this->not_const<5>(); }
      |                       ~~~~~~~~~~~~~~~~~~^~
<source>:4:41: internal compiler error: tree check: expected function_decl,
have template_decl in get_fndecl_argument_location, at cp/call.cc:8354
0x26aa1ac internal_error(char const*, ...)
        ???:0
0x96fd9e tree_check_failed(tree_node const*, char const*, int, char const*,
...)
        ???:0
0xa7d15f complain_about_bad_argument(unsigned int, tree_node*, tree_node*,
tree_node*, int)
        ???:0
0xa8c20a build_new_method_call(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, tree_node*, int, tree_node**, int)
        ???:0
0xce8267 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
        ???:0
0xc6a70a c_parse_file()
        ???:0
0xdbfcf9 c_common_parse_file()
        ???: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://gcc.gnu.org/bugs/> for instructions.
Compiler returned: 1


Online reproducer: https://godbolt.org/z/86noE3935


I would've expected something as simple as this to have been tested and fixed
long ago, but apparently not. Probably because it's just a tree check; from
what I've heard, they don't exist in versioned releases of GCC.

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

end of thread, other threads:[~2024-06-28 21:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-05 18:16 [Bug c++/115364] New: ICE-on-invalid when calling non-const template member on const object blubban at gmail dot com
2024-06-05 18:39 ` [Bug c++/115364] [11/12/13/14/15 Regression] " pinskia at gcc dot gnu.org
2024-06-06  6:48 ` rguenth at gcc dot gnu.org
2024-06-27 14:34 ` simartin at gcc dot gnu.org
2024-06-28 21:33 ` ppalka 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).