public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107904] New: __func__ is not properly treated as an array variable
@ 2022-11-29  2:14 de34 at live dot cn
  2022-11-29  3:28 ` [Bug c++/107904] " pinskia at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: de34 at live dot cn @ 2022-11-29  2:14 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107904
           Summary: __func__ is not properly treated as an array variable
           Product: gcc
           Version: 12.2.1
            Status: UNCONFIRMED
          Keywords: accepts-invalid, rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: de34 at live dot cn
  Target Milestone: ---

The following code is accepted by gcc from 4.7 to 12:

Godbolt link: https://godbolt.org/z/EYqh1f3oa

#include <type_traits>

void f()
{
    using T = decltype(__func__);
    T x = __func__;
    static_assert(std::is_lvalue_reference<T>::value, ""); // incorrectly
passes
    // static_assert(std::is_array<T>::value, ""); // incorrectly fails
}

It seems that gcc only treats __func__ as "an lvalue denoting an array object",
but not exactly "the array variable itself" specified in
[dcl.fct.def.general]/8.

Given there is an unresolved CWG issue 1962, this is possibly not a bug at this
moment. But it's unclear to me whether this is an intentional design.

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

* [Bug c++/107904] __func__ is not properly treated as an array variable
  2022-11-29  2:14 [Bug c++/107904] New: __func__ is not properly treated as an array variable de34 at live dot cn
@ 2022-11-29  3:28 ` pinskia at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-29  3:28 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=70353,
                   |                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=64266,
                   |                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=70422,
                   |                            |https://gcc.gnu.org/bugzill
                   |                            |a/show_bug.cgi?id=81277

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
>But it's unclear to me whether this is an intentional design.
I think it is but it is a bit more complex though because we did try to
implement that Defect report, see bug 70353 comment #11.
Jason made the change to fix GCC to do what CWG 1962 says and then that had to
be reverted because it broken stuff so it was decided to go back to how GCC did
it.

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

end of thread, other threads:[~2022-11-29  3:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-29  2:14 [Bug c++/107904] New: __func__ is not properly treated as an array variable de34 at live dot cn
2022-11-29  3:28 ` [Bug c++/107904] " pinskia 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).