public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/105370] New: Improved diagnostics for code from statement expressions documentation [C++ component]
@ 2022-04-24 21:01 egallager at gcc dot gnu.org
  2022-07-23 10:43 ` [Bug c++/105370] " egallager at gcc dot gnu.org
  0 siblings, 1 reply; 2+ messages in thread
From: egallager at gcc dot gnu.org @ 2022-04-24 21:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105370
           Summary: Improved diagnostics for code from statement
                    expressions documentation [C++ component]
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: diagnostic, documentation
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: egallager at gcc dot gnu.org
  Target Milestone: ---

This is the C++ counterpart to bug 105369. Code is taken from GCC documentation
on Statement Expressions here:
https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs

Testcase:

$ cat stmt_exprsxx.cc
class A
{
public:
    int Foo(void);
};

int decay(void)
{
    A a;
    return ({a;}).Foo();
}

#define X decay
#define macro(a)  ({__typeof__(a) b = (a); b + 3; })
template<typename T> T function(T a) { T b = a; return b + 3; }

void foobar()
{
  macro(X());
  function(X());
}
$

The documentation says that there might be surprising behavior about
temporaries and construction and destruction, which lead the documentation to
the conclusion that "[t]hese considerations mean that it is probably a bad idea
to use statement expressions of this form in header files that are designed to
work with C++." Perhaps there should be some warning about this (current code
doesn't print any warnings with -Wall -Wextra -Weffc++ -pedantic).

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

* [Bug c++/105370] Improved diagnostics for code from statement expressions documentation [C++ component]
  2022-04-24 21:01 [Bug c++/105370] New: Improved diagnostics for code from statement expressions documentation [C++ component] egallager at gcc dot gnu.org
@ 2022-07-23 10:43 ` egallager at gcc dot gnu.org
  0 siblings, 0 replies; 2+ messages in thread
From: egallager at gcc dot gnu.org @ 2022-07-23 10:43 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|776                         |772

--- Comment #1 from Eric Gallager <egallager at gcc dot gnu.org> ---
oops I made a typo in the "Blocks" field; fixing it


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=772
[Bug 772] Statement expressions issues
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=776
[Bug 776] large arrays causes Internal compiler error in
`assign_stack_temp_for_type'

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

end of thread, other threads:[~2022-07-23 10:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-24 21:01 [Bug c++/105370] New: Improved diagnostics for code from statement expressions documentation [C++ component] egallager at gcc dot gnu.org
2022-07-23 10:43 ` [Bug c++/105370] " egallager 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).