public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/69836] compilation error with constexpr in template types with redeclared methods
       [not found] <bug-69836-4@http.gcc.gnu.org/bugzilla/>
@ 2021-12-07 19:01 ` pinskia at gcc dot gnu.org
  2021-12-07 19:14 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-07 19:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I wonder if this is just invalid code but no diagnostic required as state
changes inside the scope of TemplateObject.

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

* [Bug c++/69836] compilation error with constexpr in template types with redeclared methods
       [not found] <bug-69836-4@http.gcc.gnu.org/bugzilla/>
  2021-12-07 19:01 ` [Bug c++/69836] compilation error with constexpr in template types with redeclared methods pinskia at gcc dot gnu.org
@ 2021-12-07 19:14 ` pinskia at gcc dot gnu.org
  2023-02-01 20:21 ` jason at gcc dot gnu.org
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-07 19:14 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> I wonder if this is just invalid code but no diagnostic required as state
> changes inside the scope of TemplateObject.

That is it needs to be reinterpret it after the parsing and needs to same
inside the scope itself. Like types of the same name should stay the same if
used inside the class.

Like:

typedef int t;
class y
{
  typedef t u;
  typedef float t;
};
Which GCC only handles currently:
<source>:5:17: error: declaration of 'typedef float y::t' changes meaning of
't' [-fpermissive]
    5 |   typedef float t;
      |                 ^
<source>:1:13: note: 't' declared here as 'typedef int t'
    1 | typedef int t;
      |             ^

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

* [Bug c++/69836] compilation error with constexpr in template types with redeclared methods
       [not found] <bug-69836-4@http.gcc.gnu.org/bugzilla/>
  2021-12-07 19:01 ` [Bug c++/69836] compilation error with constexpr in template types with redeclared methods pinskia at gcc dot gnu.org
  2021-12-07 19:14 ` pinskia at gcc dot gnu.org
@ 2023-02-01 20:21 ` jason at gcc dot gnu.org
  2023-02-01 20:38 ` jason at gcc dot gnu.org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2023-02-01 20:21 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
                 CC|                            |jason at gcc dot gnu.org
   Last reconfirmed|                            |2023-02-01

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #3)
> (In reply to Andrew Pinski from comment #2)
> > I wonder if this is just invalid code but no diagnostic required as state
> > changes inside the scope of TemplateObject.
> 
> That is it needs to be reinterpret it after the parsing and needs to same
> inside the scope itself. Like types of the same name should stay the same if
> used inside the class.

I have not considered that rule to apply to additional overloads.  Here, the
problem looks to be that we're re-calculating the type of w_counter inside the
function definition (where the current function is in the overload set) rather
than using the actual parameter type (which is calculated before the current
function is in the overload set).

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

* [Bug c++/69836] compilation error with constexpr in template types with redeclared methods
       [not found] <bug-69836-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2023-02-01 20:21 ` jason at gcc dot gnu.org
@ 2023-02-01 20:38 ` jason at gcc dot gnu.org
  2023-04-26 21:16 ` cvs-commit at gcc dot gnu.org
  2023-05-03  4:37 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2023-02-01 20:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Jason Merrill from comment #4)
> Here, the
> problem looks to be that we're re-calculating the type of w_counter inside
> the function definition (where the current function is in the overload set)
> rather than using the actual parameter type (which is calculated before the
> current function is in the overload set).

Ah, the actual problem is regenerate_decl_from_template changing the type of
w_counter.

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

* [Bug c++/69836] compilation error with constexpr in template types with redeclared methods
       [not found] <bug-69836-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2023-02-01 20:38 ` jason at gcc dot gnu.org
@ 2023-04-26 21:16 ` cvs-commit at gcc dot gnu.org
  2023-05-03  4:37 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-04-26 21:16 UTC (permalink / raw)
  To: gcc-bugs

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

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

https://gcc.gnu.org/g:1e27e7e0985e055b3d4ec92e93976b709fdbe425

commit r14-277-g1e27e7e0985e055b3d4ec92e93976b709fdbe425
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Feb 1 17:00:48 2023 -0500

    c++: unique friend shenanigans [PR69836]

    Normally we re-instantiate a function declaration when we start to
    instantiate the body in case of multiple declarations.  In this wacky
    testcase, this causes a problem because the type of the w_counter parameter
    depends on its declaration not being in scope yet, so the name lookup only
    finds the previous declaration.  This isn't a problem for member functions,
    since they aren't subject to argument-dependent lookup.  So let's just skip
    the regeneration for hidden friends.

            PR c++/69836

    gcc/cp/ChangeLog:

            * pt.cc (regenerate_decl_from_template): Skip unique friends.

    gcc/testsuite/ChangeLog:

            * g++.dg/template/friend76.C: New test.

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

* [Bug c++/69836] compilation error with constexpr in template types with redeclared methods
       [not found] <bug-69836-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2023-04-26 21:16 ` cvs-commit at gcc dot gnu.org
@ 2023-05-03  4:37 ` jason at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2023-05-03  4:37 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |14.0

--- Comment #7 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed for GCC 14.

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

end of thread, other threads:[~2023-05-03  4:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-69836-4@http.gcc.gnu.org/bugzilla/>
2021-12-07 19:01 ` [Bug c++/69836] compilation error with constexpr in template types with redeclared methods pinskia at gcc dot gnu.org
2021-12-07 19:14 ` pinskia at gcc dot gnu.org
2023-02-01 20:21 ` jason at gcc dot gnu.org
2023-02-01 20:38 ` jason at gcc dot gnu.org
2023-04-26 21:16 ` cvs-commit at gcc dot gnu.org
2023-05-03  4:37 ` jason 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).