public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/109480] New: g++-12 and g++-11 failed to compile the attached source file while g++-10 and clang can.
@ 2023-04-12  5:38 ishikawa at yk dot rim.or.jp
  2023-04-12  5:51 ` [Bug c++/109480] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: ishikawa at yk dot rim.or.jp @ 2023-04-12  5:38 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109480
           Summary: g++-12 and g++-11 failed to compile the attached
                    source file while g++-10 and clang can.
           Product: gcc
           Version: 11.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ishikawa at yk dot rim.or.jp
  Target Milestone: ---

Created attachment 54837
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54837&action=edit
target.cpp:  this shows the compiler issue for g++-10 and g++-11

I am reporting a reduced case of a compilation issue noticed when we compile
mozilla firefox browser, and thunderbird mail client software.
For the original problem report and the workaround (basically rewriting the
source code), see the bugzilla entry at mozilla's bugzilla, 
https://bugzilla.mozilla.org/show_bug.cgi?id=1825516

Now, I am a newbie to c-vise source coded reduction tool, but managed to create
the attached reduced source file.
That file shows the symptom.

I am using the following compiler for testing.
Version Info:
g++-10 --version
g++-10 (Debian 10.4.0-7) 10.4.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

ishikawa@ip030:~/Dropbox/TB-DIR/WALL-PATCH-DIR$ g++-11 --version
g++-11 (Debian 11.3.0-12) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

ishikawa@ip030:~/Dropbox/TB-DIR/WALL-PATCH-DIR$ g++-12 --version
g++-12 (Debian 12.2.0-14) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

ishikawa@ip030:~/Dropbox/TB-DIR/WALL-PATCH-DIR$ clang --version
clang version 15.0.5 (taskcluster-ETTsfeYjQ76jbYk0xzOrPA)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/ishikawa/.mozbuild/clang/bin


The clang compiler I use is a version compiled by mozilla to facilitate that
the developer community uses the same clang everywhere.

g++-10 can compile it.
g++-11 can not.
g++-12 can not.
clang can.
See the console log below.

ishikawa@ip030:~/Dropbox/TB-DIR/WALL-PATCH-DIR$ g++-10 -c target.cpp
ishikawa@ip030:~/Dropbox/TB-DIR/WALL-PATCH-DIR$ g++-11 -c target.cpp
target.cpp: In member function ‘void
mozilla::a11y::RemoteAccessibleBase<Derived>::BoundsWithOffset() const’:
target.cpp:14:57: error: ‘bool
mozilla::a11y::RemoteAccessibleBase<Derived>::ApplyScrollOffset(nsRect&) const
[with Derived = mozilla::a11y::RemoteAccessible]’ is protected within this
context
   14 |   const bool hasScrollArea = remoteAcc.ApplyScrollOffset(bounds);
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
target.cpp:6:14: note: declared protected here
    6 |         bool ApplyScrollOffset(nsRect & a) const { return a.x > 0 ?
true: false; } ;
      |              ^~~~~~~~~~~~~~~~~
ishikawa@ip030:~/Dropbox/TB-DIR/WALL-PATCH-DIR$ g++-12 -c target.cpp
target.cpp: In member function ‘void
mozilla::a11y::RemoteAccessibleBase<Derived>::BoundsWithOffset() const’:
target.cpp:14:57: error: ‘bool
mozilla::a11y::RemoteAccessibleBase<Derived>::ApplyScrollOffset(nsRect&) const
[with Derived = mozilla::a11y::RemoteAccessible]’ is protected within this
context
   14 |   const bool hasScrollArea = remoteAcc.ApplyScrollOffset(bounds);
      |                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
target.cpp:6:14: note: declared protected here
    6 |         bool ApplyScrollOffset(nsRect & a) const { return a.x > 0 ?
true: false; } ;
      |              ^~~~~~~~~~~~~~~~~
ishikawa@ip030:~/Dropbox/TB-DIR/WALL-PATCH-DIR$ clang -c target.cpp
ishikawa@ip030:~/Dropbox/TB-DIR/WALL-PATCH-DIR$ 


Thank you for sharing the great compiler suite with the developer community.

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

* [Bug c++/109480] g++-12 and g++-11 failed to compile the attached source file while g++-10 and clang can.
  2023-04-12  5:38 [Bug c++/109480] New: g++-12 and g++-11 failed to compile the attached source file while g++-10 and clang can ishikawa at yk dot rim.or.jp
@ 2023-04-12  5:51 ` pinskia at gcc dot gnu.org
  2023-04-12  6:02 ` [Bug c++/109480] [11/12/13 Regression] non-depedent access goes wrong in a template method sometimes pinskia at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-12  5:51 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Adding:

    template <class> friend struct RemoteAccessibleBase;

To the RemoteAccessibleBase template struct fixes the issue ....

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

* [Bug c++/109480] [11/12/13 Regression] non-depedent access goes wrong in a template method sometimes
  2023-04-12  5:38 [Bug c++/109480] New: g++-12 and g++-11 failed to compile the attached source file while g++-10 and clang can ishikawa at yk dot rim.or.jp
  2023-04-12  5:51 ` [Bug c++/109480] " pinskia at gcc dot gnu.org
@ 2023-04-12  6:02 ` pinskia at gcc dot gnu.org
  2023-04-12  6:06 ` pinskia at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-12  6:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=41437
           Keywords|                            |rejects-valid
            Summary|g++-12 and g++-11 failed to |[11/12/13 Regression]
                   |compile the attached source |non-depedent access goes
                   |file while g++-10 and clang |wrong in a template method
                   |can.                        |sometimes

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Most likely this was caused by r11-1350 .

Reduced further:
```
template <class> struct s {
protected:
  bool g();
  void f();
  //template <class> friend struct s;
};
template <class d>
void s<d>::f()  {
  s<int> l;
  const bool b = l.g();
}
```

This means also s<int>::f would be the only valid specialization here too.

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

* [Bug c++/109480] [11/12/13 Regression] non-depedent access goes wrong in a template method sometimes
  2023-04-12  5:38 [Bug c++/109480] New: g++-12 and g++-11 failed to compile the attached source file while g++-10 and clang can ishikawa at yk dot rim.or.jp
  2023-04-12  5:51 ` [Bug c++/109480] " pinskia at gcc dot gnu.org
  2023-04-12  6:02 ` [Bug c++/109480] [11/12/13 Regression] non-depedent access goes wrong in a template method sometimes pinskia at gcc dot gnu.org
@ 2023-04-12  6:06 ` pinskia at gcc dot gnu.org
  2023-04-12  6:55 ` [Bug c++/109480] [11/12/13 Regression] non-depedent access goes wrong in a template method sometimes since r11-1350-g92bed036098928 marxin at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-04-12  6:06 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.4

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

* [Bug c++/109480] [11/12/13 Regression] non-depedent access goes wrong in a template method sometimes since r11-1350-g92bed036098928
  2023-04-12  5:38 [Bug c++/109480] New: g++-12 and g++-11 failed to compile the attached source file while g++-10 and clang can ishikawa at yk dot rim.or.jp
                   ` (2 preceding siblings ...)
  2023-04-12  6:06 ` pinskia at gcc dot gnu.org
@ 2023-04-12  6:55 ` marxin at gcc dot gnu.org
  2023-04-12 10:31 ` rguenth at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-04-12  6:55 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |ppalka at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2023-04-12
            Summary|[11/12/13 Regression]       |[11/12/13 Regression]
                   |non-depedent access goes    |non-depedent access goes
                   |wrong in a template method  |wrong in a template method
                   |sometimes                   |sometimes since
                   |                            |r11-1350-g92bed036098928

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> Most likely this was caused by r11-1350 .

Yes.

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

* [Bug c++/109480] [11/12/13 Regression] non-depedent access goes wrong in a template method sometimes since r11-1350-g92bed036098928
  2023-04-12  5:38 [Bug c++/109480] New: g++-12 and g++-11 failed to compile the attached source file while g++-10 and clang can ishikawa at yk dot rim.or.jp
                   ` (3 preceding siblings ...)
  2023-04-12  6:55 ` [Bug c++/109480] [11/12/13 Regression] non-depedent access goes wrong in a template method sometimes since r11-1350-g92bed036098928 marxin at gcc dot gnu.org
@ 2023-04-12 10:31 ` rguenth at gcc dot gnu.org
  2023-04-12 12:40 ` ppalka at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-12 10:31 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

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

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

* [Bug c++/109480] [11/12/13 Regression] non-depedent access goes wrong in a template method sometimes since r11-1350-g92bed036098928
  2023-04-12  5:38 [Bug c++/109480] New: g++-12 and g++-11 failed to compile the attached source file while g++-10 and clang can ishikawa at yk dot rim.or.jp
                   ` (4 preceding siblings ...)
  2023-04-12 10:31 ` rguenth at gcc dot gnu.org
@ 2023-04-12 12:40 ` ppalka at gcc dot gnu.org
  2023-05-07 14:29 ` [Bug c++/109480] [11/12/13/14 " cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-04-12 12:40 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

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

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

* [Bug c++/109480] [11/12/13/14 Regression] non-depedent access goes wrong in a template method sometimes since r11-1350-g92bed036098928
  2023-04-12  5:38 [Bug c++/109480] New: g++-12 and g++-11 failed to compile the attached source file while g++-10 and clang can ishikawa at yk dot rim.or.jp
                   ` (5 preceding siblings ...)
  2023-04-12 12:40 ` ppalka at gcc dot gnu.org
@ 2023-05-07 14:29 ` cvs-commit at gcc dot gnu.org
  2023-05-07 14:30 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-07 14:29 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:7f4840ddef9746ab591c78ecdd750e3b18aa1ce6

commit r14-556-g7f4840ddef9746ab591c78ecdd750e3b18aa1ce6
Author: Patrick Palka <ppalka@redhat.com>
Date:   Sun May 7 10:24:49 2023 -0400

    c++: potentiality of templated memfn call [PR109480]

    Here we're incorrectly deeming the templated call a.g() inside b's
    initializer as potentially constant, despite g being non-constexpr,
    which leads to us needlessly instantiating the initializer ahead of time
    and which subsequently triggers a bug in access checking deferral (to be
    fixed by the follow-up patch).

    This patch fixes this by calling get_fns earlier during CALL_EXPR
    potentiality checking so that when we extract a FUNCTION_DECL out of a
    templated member function call (whose overall callee is typically a
    COMPONENT_REF) we do the usual constexpr-eligibility checking for it.

    In passing, I noticed the nearby special handling of the object argument
    of a non-static member function call is effectively the same as the
    generic argument handling a few lines below.  So this patch just gets
    rid of this special handling; otherwise we'd have to adapt it to handle
    templated versions of such calls.

            PR c++/109480

    gcc/cp/ChangeLog:

            * constexpr.cc (potential_constant_expression_1) <case CALL_EXPR>:
            Reorganize to call get_fns sooner.  Remove special handling of
            the object argument of a non-static member function call.  Remove
            dead store to 'fun'.

    gcc/testsuite/ChangeLog:

            * g++.dg/cpp0x/noexcept59.C: Make e() constexpr so that the
            expected "without object" diagnostic isn't replaced by a
            "call to non-constexpr function" diagnostic.
            * g++.dg/template/non-dependent25.C: New test.

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

* [Bug c++/109480] [11/12/13/14 Regression] non-depedent access goes wrong in a template method sometimes since r11-1350-g92bed036098928
  2023-04-12  5:38 [Bug c++/109480] New: g++-12 and g++-11 failed to compile the attached source file while g++-10 and clang can ishikawa at yk dot rim.or.jp
                   ` (6 preceding siblings ...)
  2023-05-07 14:29 ` [Bug c++/109480] [11/12/13/14 " cvs-commit at gcc dot gnu.org
@ 2023-05-07 14:30 ` cvs-commit at gcc dot gnu.org
  2023-05-07 14:31 ` [Bug c++/109480] [11/12/13 " ppalka at gcc dot gnu.org
  2023-05-29 10:08 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-05-07 14:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:681ba2f7681f295a102cd63ffd5ce2b86a5f706e

commit r14-557-g681ba2f7681f295a102cd63ffd5ce2b86a5f706e
Author: Patrick Palka <ppalka@redhat.com>
Date:   Sun May 7 10:24:52 2023 -0400

    c++: non-dep init folding and access checking [PR109480]

    enforce_access currently checks processing_template_decl to decide
    whether to defer the given access check until instantiation time.
    But using this flag is unreliable because it gets cleared during e.g.
    non-dependent initializer folding, and so can lead to premature access
    check failures as in the below testcase.  It seems better to check
    current_template_parms instead.

            PR c++/109480

    gcc/cp/ChangeLog:

            * semantics.cc (enforce_access): Check current_template_parms
            instead of processing_template_decl when deciding whether to
            defer the access check.

    gcc/testsuite/ChangeLog:

            * g++.dg/template/non-dependent25a.C: New test.

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

* [Bug c++/109480] [11/12/13 Regression] non-depedent access goes wrong in a template method sometimes since r11-1350-g92bed036098928
  2023-04-12  5:38 [Bug c++/109480] New: g++-12 and g++-11 failed to compile the attached source file while g++-10 and clang can ishikawa at yk dot rim.or.jp
                   ` (7 preceding siblings ...)
  2023-05-07 14:30 ` cvs-commit at gcc dot gnu.org
@ 2023-05-07 14:31 ` ppalka at gcc dot gnu.org
  2023-05-29 10:08 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: ppalka at gcc dot gnu.org @ 2023-05-07 14:31 UTC (permalink / raw)
  To: gcc-bugs

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

Patrick Palka <ppalka at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[11/12/13/14 Regression]    |[11/12/13 Regression]
                   |non-depedent access goes    |non-depedent access goes
                   |wrong in a template method  |wrong in a template method
                   |sometimes since             |sometimes since
                   |r11-1350-g92bed036098928    |r11-1350-g92bed036098928

--- Comment #6 from Patrick Palka <ppalka at gcc dot gnu.org> ---
Fixed on trunk so far.

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

* [Bug c++/109480] [11/12/13 Regression] non-depedent access goes wrong in a template method sometimes since r11-1350-g92bed036098928
  2023-04-12  5:38 [Bug c++/109480] New: g++-12 and g++-11 failed to compile the attached source file while g++-10 and clang can ishikawa at yk dot rim.or.jp
                   ` (8 preceding siblings ...)
  2023-05-07 14:31 ` [Bug c++/109480] [11/12/13 " ppalka at gcc dot gnu.org
@ 2023-05-29 10:08 ` jakub at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-29 10:08 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.4                        |11.5

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.4 is being released, retargeting bugs to GCC 11.5.

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

end of thread, other threads:[~2023-05-29 10:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-12  5:38 [Bug c++/109480] New: g++-12 and g++-11 failed to compile the attached source file while g++-10 and clang can ishikawa at yk dot rim.or.jp
2023-04-12  5:51 ` [Bug c++/109480] " pinskia at gcc dot gnu.org
2023-04-12  6:02 ` [Bug c++/109480] [11/12/13 Regression] non-depedent access goes wrong in a template method sometimes pinskia at gcc dot gnu.org
2023-04-12  6:06 ` pinskia at gcc dot gnu.org
2023-04-12  6:55 ` [Bug c++/109480] [11/12/13 Regression] non-depedent access goes wrong in a template method sometimes since r11-1350-g92bed036098928 marxin at gcc dot gnu.org
2023-04-12 10:31 ` rguenth at gcc dot gnu.org
2023-04-12 12:40 ` ppalka at gcc dot gnu.org
2023-05-07 14:29 ` [Bug c++/109480] [11/12/13/14 " cvs-commit at gcc dot gnu.org
2023-05-07 14:30 ` cvs-commit at gcc dot gnu.org
2023-05-07 14:31 ` [Bug c++/109480] [11/12/13 " ppalka at gcc dot gnu.org
2023-05-29 10:08 ` jakub 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).