public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94264] New: Array-to-pointer conversion not performed on array prvalues
@ 2020-03-23  0:21 ndkrempel at gmail dot com
  2020-04-18 16:33 ` [Bug c++/94264] " mpolacek at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: ndkrempel at gmail dot com @ 2020-03-23  0:21 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94264
           Summary: Array-to-pointer conversion not performed on array
                    prvalues
           Product: gcc
           Version: 9.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ndkrempel at gmail dot com
  Target Milestone: ---

I think the most clearcut example is:

int main() {
  using T = int[];
  T{1, 2} == nullptr;
}

This compiles fine with clang, and is supported by the standard: the ==
operator explicitly performs array-to-pointer conversion
(https://eel.is/c++draft/expr#eq-1), and array-to-pointer conversion is
explicitly defined for rvalue arrays (https://eel.is/c++draft/expr#conv.array).

Other examples (which again all compile with clang) are:

+T{1, 2};
  Here the standard wording seems to have a minor bug, as unary "+" does not
explicitly perform the array-to-pointer conversion, and the general rubric for
applying it (https://eel.is/c++draft/expr#basic.lval-6) only applies to
glvalues as written.

T{1, 2} + 1;
  Ditto.

*(T{1, 2} + 1);
  Interesting as T{1, 2}[1] should be equivalent to this (modulo the value
category of the result, https://eel.is/c++draft/expr#sub), yet the former is
rejected by gcc and the latter accepted.

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

end of thread, other threads:[~2023-12-19 20:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-23  0:21 [Bug c++/94264] New: Array-to-pointer conversion not performed on array prvalues ndkrempel at gmail dot com
2020-04-18 16:33 ` [Bug c++/94264] " mpolacek at gcc dot gnu.org
2021-08-10  3:43 ` pinskia at gcc dot gnu.org
2021-10-02 20:01 ` pinskia at gcc dot gnu.org
2023-10-08  7:31 ` fchelnokov at gmail dot com
2023-10-09  2:07 ` de34 at live dot cn
2023-10-09  2:19 ` pinskia at gcc dot gnu.org
2023-11-28 18:05 ` jason at gcc dot gnu.org
2023-11-28 21:29 ` cvs-commit at gcc dot gnu.org
2023-12-08 18:34 ` cvs-commit at gcc dot gnu.org
2023-12-19 20:54 ` 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).