Click here to Skip to main content
15,791,740 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: For loop Pin
jschell26-Sep-23 6:10
jschell26-Sep-23 6:10 
GeneralRe: For loop Pin
Randor 26-Sep-23 6:38
professional Randor 26-Sep-23 6:38 
GeneralRe: For loop Pin
jschell27-Sep-23 6:23
jschell27-Sep-23 6:23 
JokeRe: For loop Pin
Randor 27-Sep-23 7:57
professional Randor 27-Sep-23 7:57 
GeneralRe: For loop Pin
trønderen28-Sep-23 14:50
trønderen28-Sep-23 14:50 
GeneralRe: For loop Pin
jschell29-Sep-23 12:07
jschell29-Sep-23 12:07 
GeneralRe: For loop Pin
trønderen29-Sep-23 12:35
trønderen29-Sep-23 12:35 
GeneralRe: For loop Pin
Randor 29-Sep-23 13:04
professional Randor 29-Sep-23 13: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 6:09
jschell2-Oct-23 6:09 
GeneralRe: For loop Pin
Randor 2-Oct-23 6:47
professional Randor 2-Oct-23 6:47 
GeneralRe: For loop Pin
trønderen2-Oct-23 9:01
trønderen2-Oct-23 9:01 
GeneralRe: For loop Pin
Randor 2-Oct-23 9:27
professional Randor 2-Oct-23 9:27 
GeneralRe: For loop Pin
trønderen2-Oct-23 13:17
trønderen2-Oct-23 13:17 
GeneralRe: For loop Pin
Randor 2-Oct-23 13:54
professional Randor 2-Oct-23 13:54 
GeneralRe: For loop Pin
trønderen2-Oct-23 22:11
trønderen2-Oct-23 22:11 
GeneralRe: For loop Pin
Randor 3-Oct-23 1:08
professional Randor 3-Oct-23 1:08 
GeneralRe: For loop Pin
trønderen3-Oct-23 10:54
trønderen3-Oct-23 10:54 
GeneralRe: For loop Pin
jschell3-Oct-23 5:35
jschell3-Oct-23 5:35 
GeneralRe: For loop Pin
k505429-Sep-23 12:55
mvek505429-Sep-23 12:55 
GeneralRe: For loop Pin
Randor 29-Sep-23 13:14
professional Randor 29-Sep-23 13:14 
GeneralRe: For loop Pin
honey the codewitch3-Oct-23 13:32
mvahoney the codewitch3-Oct-23 13:32 
AnswerRe: For loop Pin
Dave Kreskowiak25-Sep-23 9:53
mveDave Kreskowiak25-Sep-23 9:53 
GeneralRe: For loop Pin
Calin Negru25-Sep-23 23:40
Calin Negru25-Sep-23 23:40 
GeneralRe: For loop Pin
Richard Andrew x6428-Sep-23 13:12
professionalRichard Andrew x6428-Sep-23 13:12 
GeneralRe: For loop Pin
Dave Kreskowiak28-Sep-23 13:20
mveDave Kreskowiak28-Sep-23 13: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.