public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/107065] New: GCC treats rvalue like lvalue
@ 2022-09-28  7:35 jlame646 at gmail dot com
  2022-09-28 12:00 ` [Bug c++/107065] GCC treats rvalue as an lvalue redi at gcc dot gnu.org
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: jlame646 at gmail dot com @ 2022-09-28  7:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107065
           Summary: GCC treats rvalue like lvalue
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jlame646 at gmail dot com
  Target Milestone: ---

In the following program gcc incorrectly treats the expression `!(!b)` as
lvalue. Demo: https://godbolt.org/z/zv5En5hjG

```
#include <iostream>
template<typename T>
struct value_category {
    // Or can be an integral or enum value
    static constexpr auto value = "prvalue";
};

template<typename T>
struct value_category<T&> {
    static constexpr auto value = "lvalue";
};

template<typename T>
struct value_category<T&&> {
    static constexpr auto value = "xvalue";
};

// Double parens for ensuring we inspect an expression,
// not an entity
#define VALUE_CATEGORY(expr) value_category<decltype((expr))>::value

int main() {
    bool b = true;

    std::cout << VALUE_CATEGORY(!(!b)); //gcc wrongly prints lvalue
}

```

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

end of thread, other threads:[~2023-05-04  7:20 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28  7:35 [Bug c++/107065] New: GCC treats rvalue like lvalue jlame646 at gmail dot com
2022-09-28 12:00 ` [Bug c++/107065] GCC treats rvalue as an lvalue redi at gcc dot gnu.org
2022-09-28 12:06 ` jlame646 at gmail dot com
2022-09-28 12:09 ` jlame646 at gmail dot com
2022-09-28 12:50 ` redi at gcc dot gnu.org
2022-09-28 13:41 ` mpolacek at gcc dot gnu.org
2022-09-28 14:32 ` jlame646 at gmail dot com
2022-09-28 15:34 ` mpolacek at gcc dot gnu.org
2022-09-29 18:24 ` glisse at gcc dot gnu.org
2022-09-29 19:01 ` jakub at gcc dot gnu.org
2022-09-30  7:12 ` jakub at gcc dot gnu.org
2022-09-30  7:13 ` jakub at gcc dot gnu.org
2022-09-30  8:03 ` glisse at gcc dot gnu.org
2022-09-30  8:27 ` jakub at gcc dot gnu.org
2022-09-30  8:47 ` glisse at gcc dot gnu.org
2022-12-15 18:18 ` cvs-commit at gcc dot gnu.org
2022-12-16  9:23 ` jakub at gcc dot gnu.org
2023-02-10 17:44 ` cvs-commit at gcc dot gnu.org
2023-05-02 20:12 ` cvs-commit at gcc dot gnu.org
2023-05-03 15:19 ` cvs-commit at gcc dot gnu.org
2023-05-04  7:20 ` 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).