Title
Block-scope declaration conflicting with parameter name
Status
drwp
Section
6.4.3 [basic.scope.block]
Submitter
Jason Merrill

Created on 2023-08-31.00:00:00 last changed 3 weeks ago

Messages

Date: 2023-09-15.21:51:11

Proposed resolution (approved by CWG 2023-09-15):

If a declaration that is not a name-independent declaration and whose target scope is that binds a name in the block scope S of a
  • compound-statement of a lambda-expression, function-body, or function-try-block,
  • substatement of a selection or iteration statement that is not itself a selection or iteration statement, or
  • handler of a function-try-block
potentially conflicts with a declaration whose target scope is the parent scope of S, the program is ill-formed.
Date: 2023-11-15.00:00:00

[Accepted as a DR at the November, 2023 meeting.]

Consider:

  void f(int i) { extern int i; } 

According to 6.4.3 [basic.scope.block] paragraph 2, the target scope of the declaration is relevant (which would be the global scope), but not the scope in which the name is bound. That seems wrong. For comparison, template parameter names use the latter rule (13.8.2 [temp.local] paragraph 6).

History
Date User Action Args
2024-04-05 21:43:46adminsetstatus: dr -> drwp
2023-12-19 10:15:28adminsetstatus: ready -> dr
2023-09-15 21:51:11adminsetstatus: open -> ready
2023-09-02 07:30:49adminsetmessages: + msg7420
2023-08-31 00:00:00admincreate