Block-scope declaration conflicting with parameter name
6.4.3 [basic.scope.block]
Jason Merrill

Created on 2023-08-31.00:00:00 last changed 5 days ago


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-08-31.00:00:00


  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).

Date User Action Args
2023-09-15 21:51:11adminsetstatus: open -> ready
2023-09-02 07:30:49adminsetmessages: + msg7420
2023-08-31 00:00:00admincreate