C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [PXXXXR0] Add a New Keyword `undecl`

From: wjf <wjf_at_[hidden]>
Date: Wed, 10 Dec 2025 17:23:51 +0800
I think it's the compiler job to prevent the skip of undecl&nbsp; statement in some branch of program flow. For example the following code is forbidden too.


//...
{
&nbsp; &nbsp; int x = 1;
illegal_entry_point:
&nbsp; &nbsp; //...
}


goto&nbsp;illegal_entry_point; //wrong code



---Original---
From: "Sebastian Wittmeier via Std-Proposals"<std-proposals_at_[hidden]&gt;
Date: Wed, Dec 10, 2025 12:04 PM
To: "Std-Proposals"<std-proposals_at_[hidden]&gt;;
Cc: "Sebastian Wittmeier"<wittmeier_at_[hidden]&gt;;
Subject: Re: [std-proposals] [PXXXXR0] Add a New Keyword `undecl`


            
One can do the same without brace levels by using switch case or goto.
&nbsp;
-----Ursprüngliche Nachricht-----
Von: Breno Guimarães <brenorg_at_[hidden]&gt;
Gesendet: Mi 10.12.2025 02:35
Betreff: Re: [std-proposals] [PXXXXR0] Add a New Keyword `undecl`
An: Std-Proposals <std-proposals_at_[hidden]&gt;;
CC: Sebastian Wittmeier <wittmeier_at_[hidden]&gt;;
The paper says that undecl can only be called in the same brace level as the declaration. So I guess this example isn't valid.

Em ter., 9 de dez. de 2025, 22:29, Sebastian Wittmeier via Std-Proposals <std-proposals_at_[hidden]&gt; escreveu:
               
undeclaring a variable is the same as relocating from a variable to nothingness (or to somewhere else).

&nbsp;

A variable, which was relocated from, may also not be used any longer afterwards.

&nbsp;

&nbsp;

One detail may be the difference between position in the program (source code line within the block) and program flow.

&nbsp;

int a = -1;

for (int i = 0; i < 10; i++) {

&nbsp;&nbsp;&nbsp; if (i == 5)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a++; // can a be used here?

&nbsp;&nbsp;&nbsp; if (i == 4)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; undecl a;

&nbsp;&nbsp;&nbsp; if (i == 5)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a++; // and here?

}

&nbsp;
-----Ursprüngliche Nachricht-----
Von: wjf via Std-Proposals <std-proposals_at_[hidden]&gt;
Gesendet: Mi 10.12.2025 02:23
Betreff: [std-proposals] [PXXXXR0] Add a New Keyword `undecl`
Anlage: Add_New_Keyword_undecl.pdf
An: std-proposals <std-proposals_at_[hidden]&gt;;
CC: wjf <wjf_at_[hidden]&gt;;
  see attachment
&nbsp;

wjf
wjf_at_[hidden]



&nbsp;
 -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
 --
 Std-Proposals mailing list
 Std-Proposals_at_[hidden]
 https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2025-12-10 09:23:59