Bug 95016 - [DR 2082] Referring to parameters in unevaluated operands of default arguments
Summary: [DR 2082] Referring to parameters in unevaluated operands of default arguments
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Marek Polacek
URL:
Keywords:
Depends on:
Blocks: c++-core-issues
  Show dependency treegraph
 
Reported: 2020-05-08 20:16 UTC by Marek Polacek
Modified: 2021-11-06 03:16 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-05-08 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Polacek 2020-05-08 20:16:19 UTC
We give two errors here:

void
f ()
{
  int i;
  extern void g(int x = i);         // error
  extern void h(int x = sizeof(i)); // OK
}

but [dcl.fct.default]/7 now says "A local variable cannot be odr-used ([basic.def.odr]) in a default argument."

This is https://wg21.link/cwg2082
Comment 1 Marek Polacek 2021-08-03 21:24:46 UTC
Will be fixed by https://gcc.gnu.org/pipermail/gcc-patches/2021-August/576627.html
Comment 2 Andrew Pinski 2021-08-17 09:54:06 UTC
Could PR 50479 be related?
Comment 3 Marek Polacek 2021-11-06 03:16:12 UTC
Fixed in GCC 11.