Implicitly treating returned lvalue as rvalue

后端 未结 2 1404
天涯浪人
天涯浪人 2020-12-16 12:45

12.8 Copying and moving class objects [class.copy] §31 and §32 say:

in a return statement in a function with a class return type, when the expres

2条回答
  •  时光取名叫无心
    2020-12-16 13:05

    Parenthesized expressions are equivalent to their unparenthesized expressions unless otherwise noted (as done in the ADL rules, for example, or by decltype for another example). It can sometimes be tricky when and when not something is equivalent in this manner (for example, the ADL rules don't explicitly mention "unparenthesized", but they use an explicit grammar non-terminal and examples that make it clear that parens are not taken as being equivalent).

    For the other questions: Yes, GCC does several optimizations on the AST directly that makes it accept various invalid programs, like the following

    int a = 42;
    int *p = 0 * a;
    

提交回复
热议问题