Click here to Skip to main content
15,887,027 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: For loop Pin
jschell26-Sep-23 5:10
jschell26-Sep-23 5:10 
GeneralRe: For loop Pin
Randor 26-Sep-23 5:38
professional Randor 26-Sep-23 5:38 
GeneralRe: For loop Pin
jschell27-Sep-23 5:23
jschell27-Sep-23 5:23 
JokeRe: For loop Pin
Randor 27-Sep-23 6:57
professional Randor 27-Sep-23 6:57 
GeneralRe: For loop Pin
trønderen28-Sep-23 13:50
trønderen28-Sep-23 13:50 
GeneralRe: For loop Pin
jschell29-Sep-23 11:07
jschell29-Sep-23 11:07 
GeneralRe: For loop Pin
trønderen29-Sep-23 11:35
trønderen29-Sep-23 11:35 
GeneralRe: For loop Pin
Randor 29-Sep-23 12:04
professional Randor 29-Sep-23 12:04 
trønderen wrote:
If variables X and Y are defined in a block, must they both be available throughout the lifetime of that block?
jschell wrote:
Via the spec? No.


Regarding C99 the lifetime is defined in 6.2.4 paragraph 2:
The lifetime of an object is the portion of program execution during which storage is
guaranteed to be reserved for it. An object exists, has a constant address,25) and retains
its last-stored value throughout its lifetime. 26) If an object is referred to outside of its
lifetime, the behavior is undefined. The value of a pointer becomes indeterminate when
the object it points to reaches the end of its lifetime.

Then paragraph 5 defines how that "lifetime" is applied in the block scope.

modified 29-Sep-23 19:38pm.

GeneralRe: For loop Pin
jschell2-Oct-23 5:09
jschell2-Oct-23 5:09 
GeneralRe: For loop Pin
Randor 2-Oct-23 5:47
professional Randor 2-Oct-23 5:47 
GeneralRe: For loop Pin
trønderen2-Oct-23 8:01
trønderen2-Oct-23 8:01 
GeneralRe: For loop Pin
Randor 2-Oct-23 8:27
professional Randor 2-Oct-23 8:27 
GeneralRe: For loop Pin
trønderen2-Oct-23 12:17
trønderen2-Oct-23 12:17 
GeneralRe: For loop Pin
Randor 2-Oct-23 12:54
professional Randor 2-Oct-23 12:54 
GeneralRe: For loop Pin
trønderen2-Oct-23 21:11
trønderen2-Oct-23 21:11 
GeneralRe: For loop Pin
Randor 3-Oct-23 0:08
professional Randor 3-Oct-23 0:08 
GeneralRe: For loop Pin
trønderen3-Oct-23 9:54
trønderen3-Oct-23 9:54 
GeneralRe: For loop Pin
jschell3-Oct-23 4:35
jschell3-Oct-23 4:35 
GeneralRe: For loop Pin
k505429-Sep-23 11:55
mvek505429-Sep-23 11:55 
GeneralRe: For loop Pin
Randor 29-Sep-23 12:14
professional Randor 29-Sep-23 12:14 
GeneralRe: For loop Pin
honey the codewitch3-Oct-23 12:32
mvahoney the codewitch3-Oct-23 12:32 
AnswerRe: For loop Pin
Dave Kreskowiak25-Sep-23 8:53
mveDave Kreskowiak25-Sep-23 8:53 
GeneralRe: For loop Pin
Calin Negru25-Sep-23 22:40
Calin Negru25-Sep-23 22:40 
GeneralRe: For loop Pin
Richard Andrew x6428-Sep-23 12:12
professionalRichard Andrew x6428-Sep-23 12:12 
GeneralRe: For loop Pin
Dave Kreskowiak28-Sep-23 12:20
mveDave Kreskowiak28-Sep-23 12:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.