• Using gotos with local variables in "extra" blocks: Does it get dealloc

    From Kenny McCormack@3:633/10 to All on Mon May 25 13:46:35 2026
    Subject: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and
    also on some of my own code, I got to wondering about the following code fragment:

    void foo(void) {
    /* stuff */
    { /* Enter an "extra" block */
    int i = 42; /* 'i' is allocated on the stack */
    /* stuff */
    if (someCond) goto OutOfHere;
    /* more stuff */
    } /* End of "extra" block */
    OutOfHere: puts("Got to OutOfHere");
    } /* End of foo() */

    Now suppose someCond is true and the branch is taken. Does the variable
    'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    Note that in most/all "scripting" languages, this code pattern would be a
    big no-no, and if you did it enough times, it will blow up the program.

    Note, BTW, that we could make this issue go away by putting OutOfHere a
    line earlier - i.e., inside the "extra" block - but then we'd run into
    Bart's issue (i.e., we'd have to put an extra ';' after the label).

    --
    "Insisting on perfect safety is for people who don't have the balls to live
    in the real world."

    - Mary Shafer, NASA Ames Dryden -

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Mon May 25 16:19:15 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 2026-05-25 15:46, Kenny McCormack wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and
    also on some of my own code, I got to wondering about the following code fragment:

    void foo(void) {
    /* stuff */
    { /* Enter an "extra" block */
    int i = 42; /* 'i' is allocated on the stack */
    /* stuff */
    if (someCond) goto OutOfHere;
    /* more stuff */
    } /* End of "extra" block */
    OutOfHere: puts("Got to OutOfHere");
    } /* End of foo() */

    Now suppose someCond is true and the branch is taken. Does the variable
    'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    If allowed by programming languages that's how this sort of
    scope-exit usually works, yes.[*] (But for a standards-proof
    answer other people have to quote the standard.) Since "C"
    supports 'goto' I see no point in doing something unexpected
    here.

    (A similar question is for (even more drastic) setjmp/longjmp
    functionality, but then you explicitly provide the environment
    information.)

    Usually a problem is with the intention to jump *into* such
    embedded scopes, not out.


    Note that in most/all "scripting" languages, this code pattern would be a
    big no-no, and if you did it enough times, it will blow up the program.

    Can you give some hints on that, or examples, please?


    Note, BTW, that we could make this issue go away by putting OutOfHere a
    line earlier - i.e., inside the "extra" block - but then we'd run into
    Bart's issue (i.e., we'd have to put an extra ';' after the label).

    Relocating the label might work for blocks, this simple case,
    but could not be used for embedded control-structures.

    Janis

    [*] I've got hinted on that fact first when I learned Pascal,
    where it had been pointed out that a harmless looking 'goto 99'
    will (have to) do all the stack-unrolling, i.e., it's not just
    a low-level (assembly-like) jump statement but behind the scenes
    non-trivial (for some values of "trivial").


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bart@3:633/10 to All on Mon May 25 15:21:44 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 25/05/2026 14:46, Kenny McCormack wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and
    also on some of my own code, I got to wondering about the following code fragment:

    void foo(void) {
    /* stuff */
    { /* Enter an "extra" block */
    int i = 42; /* 'i' is allocated on the stack */
    /* stuff */
    if (someCond) goto OutOfHere;
    /* more stuff */
    } /* End of "extra" block */
    OutOfHere: puts("Got to OutOfHere");
    } /* End of foo() */

    Now suppose someCond is true and the branch is taken. Does the variable
    'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    You'll have to wait until the experts chime in to answer that.

    Usually, simple variables like this may be allocated on the stack, but
    that merely consists of an offset within the stack frame that is
    allocated on function entry. It may share that slot with other variables
    whose lifetimes don't overlap with 'i'.

    No actual allocation or deallocation is done, so there is no problem.

    An optimising compiler is also likely to keep 'i' within a register
    anyway (or eliminate its use completely).

    With VLAs however it is a different story. I think you can jump out of a
    block which has an active VLA, but you can't jump into it, but there are machinations involved.

    Note that in most/all "scripting" languages, this code pattern would be a
    big no-no,

    Most won't have 'goto'. Some might not even have block scopes (so 'i'
    has function-wide scope). In any case there are usually more complicated things going on so extra stack manipulation would be the least of it.

    and if you did it enough times, it will blow up the program.

    That would be a poor scripting language.

    (In mine, anything goes, but it does ban 'goto' inside a try-except
    block since that pushes something onto the stack that needs to be
    properly dealt with before it leaves the block.)


    Note, BTW, that we could make this issue go away by putting OutOfHere a
    line earlier - i.e., inside the "extra" block - but then we'd run into
    Bart's issue (i.e., we'd have to put an extra ';' after the label).

    If you followed the thread you'd have realised that isn't an issue
    anymore: if you use a C23 compiler. Somebody actually took this
    'non-problem' and persuaded the C committee to fix it.



    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kenny McCormack@3:633/10 to All on Mon May 25 14:32:32 2026
    Subject: The C23 thing (Was: Using gotos with local variables in "extra" blocks: Does it get) deallocated?

    In article <10v1lto$1ceqp$1@dont-email.me>, Bart <bc@freeuk.com> wrote:
    ...
    Note, BTW, that we could make this issue go away by putting OutOfHere a
    line earlier - i.e., inside the "extra" block - but then we'd run into
    Bart's issue (i.e., we'd have to put an extra ';' after the label).

    If you followed the thread you'd have realised that isn't an issue
    anymore: if you use a C23 compiler. Somebody actually took this >'non-problem' and persuaded the C committee to fix it.

    Yes, I followed it. No, I don't have a C23 compiler. I would imagine that most people don't - unless they are the intentionally hyper-modern types.

    I had been led to believe from those threads that gcc has, as an extension, solved this earlier, but in my limited testing with (whatever version of)
    gcc is on my system, using various -std values, gcc still objects to it.

    --
    To my knowledge, Jacob Navia is not a Christian.

    - Rick C Hodgin -


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Mon May 25 16:34:18 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 2026-05-25 16:21, Bart wrote:
    On 25/05/2026 14:46, Kenny McCormack wrote:
    Trigger Warning: This post contains the dreaded "s word".˙ Viewer
    discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and
    also on some of my own code, I got to wondering about the following code
    fragment:

    ˙˙˙˙ void foo(void) {
    ˙˙˙˙/* stuff */
    ˙˙˙˙{˙˙˙ /* Enter an "extra" block */
    ˙˙˙˙int i = 42;˙˙˙ /* 'i' is allocated on the stack */
    ˙˙˙˙/* stuff */
    ˙˙˙˙if (someCond) goto OutOfHere;
    ˙˙˙˙/* more stuff */
    ˙˙˙˙}˙˙˙ /* End of "extra" block */
    ˙˙˙˙ OutOfHere: puts("Got to OutOfHere");
    ˙˙˙˙ }˙˙˙ /* End of foo() */

    Now suppose someCond is true and the branch is taken.˙ Does the variable
    'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    You'll have to wait until the experts chime in to answer that.

    Usually, simple variables like this may be allocated on the stack, but
    that merely consists of an offset within the stack frame that is
    allocated on function entry. It may share that slot with other variables whose lifetimes don't overlap with 'i'.

    I read Kenny's question as a more principle one. It can easier be
    understood in, say, C++. For example with below code we observe a
    correct allocation and de-allocation of the local objects...

    #include <stdio.h>

    class Int
    {
    public:
    Int () { puts("ctor"); };
    ~Int () { puts("dtor"); };
    };

    int main (void)
    {
    {
    int i = 42;
    Int j;
    if (1) goto OutOfHere;
    }
    OutOfHere: puts("Got to OutOfHere");
    }


    Output:
    ctor
    dtor
    Got to OutOfHere


    Janis


    No actual allocation or deallocation is done, so there is no problem.

    [...]

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Andrew Smallshaw@3:633/10 to All on Mon May 25 16:09:40 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 2026-05-25, Kenny McCormack <gazelle@shell.xmission.com> wrote:

    Based on some recent threads (mostly, the Bart vs. The World ones), and
    also on some of my own code, I got to wondering about the following code fragment:

    void foo(void) {
    /* stuff */
    { /* Enter an "extra" block */
    int i = 42; /* 'i' is allocated on the stack */
    /* stuff */
    if (someCond) goto OutOfHere;
    /* more stuff */
    } /* End of "extra" block */
    OutOfHere: puts("Got to OutOfHere");
    } /* End of foo() */

    Now suppose someCond is true and the branch is taken. Does the variable
    'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    Personally I wouldn't worry too much about, the compiler is going
    to do the right thing and speculating whether or when variables
    get allocated and released is fool's game that will vary thanks to
    the "as-if" rule. My general hunch would be that i gets allocated
    (whether on the stack or in a register) the instant foo() is entered
    and stays there until the function exits. More formally the extent
    of i is the duration of the function but it is only in scope in
    the inner block.

    If the inner block executes repeatedly (e.g. it is a loop body)
    although i is logically a fresh variable on each iteration in
    practice it will be one and the same. Again, the as-if rule kicks
    in. If the initialisation was not there there is no guarantee at
    all as to the contents of i and so the value it had on a previous
    iteration is as valid as any other.

    --
    Andrew Smallshaw
    andrews@sdf.org

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Dan Cross@3:633/10 to All on Mon May 25 16:35:29 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    In article <10v1jrr$35gqh$2@news.xmission.com>,
    Kenny McCormack <gazelle@shell.xmission.com> wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and
    also on some of my own code, I got to wondering about the following code >fragment:

    void foo(void) {
    /* stuff */
    { /* Enter an "extra" block */
    int i = 42; /* 'i' is allocated on the stack */
    /* stuff */
    if (someCond) goto OutOfHere;
    /* more stuff */
    } /* End of "extra" block */
    OutOfHere: puts("Got to OutOfHere");
    } /* End of foo() */

    Now suppose someCond is true and the branch is taken. Does the variable
    'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    The variable `i` will be deallocated, yes. But if the question
    is whether that happens immediately after the `goto` or not,
    then it's that's a different question.

    The standard says that if a variable with "automatic storage
    duration" is not a VLA (which describes `i` in this case), then
    the lifetime of the object ends when "execution of that block
    ends in any way" (sec 6.2.4 of the various standards; para 6 in
    n3220).

    Here, "lifetime" is defined as, "the portion of program
    execution during which storage is guaranteed to be reserved for
    it."

    So whether or not the storage is _immediately_ reclaimed is
    another matter; it may be immediately deallocated after exiting
    the block, or when the function returns, or some other time.

    Note that in most/all "scripting" languages, this code pattern would be a
    big no-no, and if you did it enough times, it will blow up the program.

    Huh. Which languages?

    Note, BTW, that we could make this issue go away by putting OutOfHere a
    line earlier - i.e., inside the "extra" block - but then we'd run into
    Bart's issue (i.e., we'd have to put an extra ';' after the label).

    It actually doesn't change the issue at all; whether "execution"
    of the block ends due to a `goto` out of it or reaching the end
    of the block as written is irrelevant: it'll be deallocated
    regardless. But whether that happens immediately or not is
    another matter.

    Assuming a stack-based implementation, I'd assume most compilers
    would deallocate it when the enclosing function returns.


    - Dan C.


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Mon May 25 18:40:15 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 25/05/2026 15:46, Kenny McCormack wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and
    also on some of my own code, I got to wondering about the following code fragment:

    void foo(void) {
    /* stuff */
    { /* Enter an "extra" block */
    int i = 42; /* 'i' is allocated on the stack */
    /* stuff */
    if (someCond) goto OutOfHere;
    /* more stuff */
    } /* End of "extra" block */
    OutOfHere: puts("Got to OutOfHere");
    } /* End of foo() */

    Now suppose someCond is true and the branch is taken. Does the variable
    'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    C does not really have allocating and deallocating of local variables -
    the important concepts here are the storage duration and the lifetime
    (as defined by the C standards). Then it is up to the compiler to make
    sure any relevant stack slots or registers are available during that
    lifetime.

    For a variable that is not a VLA, the lifetime starts at the entry to
    it's block and continues until that block ends in any way. That also
    applies whether you jump into the block rather than "executing" the
    opening brace, or jump out of the block rather than "executing" the
    closing brace. (For a VLA, the lifetime starts at the declaration,
    since the actual type and size of the VLA may not be known until then.)

    Initialisation is done when execution flow hits the declaration and initialisation - just like a normal assignment. And if you jump into a
    block, past the initialisation, the variable exists (it is within its lifetime) but is indeterminate (uninitialised).

    The scope is from the declaration until the end of the block. But it is possible to do weird things with goto's where you are within the
    lifetime, but outside the scope :

    int x = 123;
    int *p = &x;
    {
    label:
    printf("%i\n", *p);
    int y = 456;
    p = &y;
    x++;
    if (x == 124) goto label;
    }

    That will print "123" then "456". The second "printf" is using "*p" to
    access the storage of "y" inside its lifetime, but outside its scope.


    But if you are wondering how compilers handle code like your example,
    rather than what the semantics of it are, then there is no single fixed answer. Compilers will typically use registers for local variables
    where they can, rather than stack slots. And whether they use registers
    or stack slots, these do not have to be fixed - the same variable can be
    moved around, and multiple bits of data can be stored in the same
    register or stack slot. If the compiler doesn't actually have to store
    a value to get the correct runtime behaviour, it can eliminate the
    variable entirely. And if the stack is used, it is common for all the
    stack space to be allocated (i.e., the stack pointer decremented for a downwards-growing stack, and possibly a frame pointer set up) at the
    function entry and the stack restored at function exit - you don't
    usually see individual stack manipulations for separate variables.




    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kenny McCormack@3:633/10 to All on Mon May 25 16:54:17 2026
    Subject: The whole point of this NG is worrying about "UB" (Was: Using gotos with local variables in "extra" blocks: Does it get) deallocated?

    In article <slrn1118t24.6gi.andrews@sdf.org>,
    Andrew Smallshaw <andrews@sdf.org> wrote:
    ...
    Personally I wouldn't worry too much about, the compiler is going
    to do the right thing and speculating whether or when variables
    get allocated and ...

    But that's the whole point of this NG. That C is *not* a "safe" language.
    That getting it to compile is only the first step in having any idea that
    it will behave sensibly. I.e., you have to both know and follow the rules
    in order to be confident that you haven't done something stupid.

    Or, to put it another way, that, no, you can't rely on the compiler "doing
    the right thing", if you've violated some obscure rule.

    In a "safe" language, if it compiles, it is safe to run - e.g., BASIC (*).
    The quest of modern language research is create a language that is both
    safe and efficient. Rust (about which I know zilch, so am going only on
    what I've heard) seems to be the current "flavor of the month".

    (*) I.e., there might still be logic errors, but at least you can be sure
    that what you wrote is what gets executed.
    --
    The people who tell us to be proud of the white race are the ones who make
    us the most embarrassed by it.

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Janis Papanagnou@3:633/10 to All on Mon May 25 19:08:43 2026
    Subject: Re: The whole point of this NG is worrying about "UB" (Was: Using gotos with local variables in "extra" blocks: Does it get) deallocated?

    On 2026-05-25 18:54, Kenny McCormack wrote:
    In article <slrn1118t24.6gi.andrews@sdf.org>,
    Andrew Smallshaw <andrews@sdf.org> wrote:
    ...
    Personally I wouldn't worry too much about, the compiler is going
    to do the right thing and speculating whether or when variables
    get allocated and ...

    But that's the whole point of this NG. That C is *not* a "safe" language.

    LOL, yeah; it's (the situation) in a way pathologically schizophrenic...

    That getting it to compile is only the first step in having any idea that
    it will behave sensibly. I.e., you have to both know and follow the rules
    in order to be confident that you haven't done something stupid.

    Or, to put it another way, that, no, you can't rely on the compiler "doing the right thing", if you've violated some obscure rule.

    ...but I think another post down-thread addresses the original question sufficiently.

    Janis

    [...]


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kenny McCormack@3:633/10 to All on Mon May 25 17:23:52 2026
    Subject: Re: The whole point of this NG is worrying about "UB" (Was: Using gotos with local variables in "extra" blocks: Does it get) deallocated?

    In article <10v1vmr$1s757$7@dont-email.me>,
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    ...
    Or, to put it another way, that, no, you can't rely on the compiler "doing >> the right thing", if you've violated some obscure rule.

    ...but I think another post down-thread addresses the original question >sufficiently.

    Agreed. I think I've got my answer.

    When you get right down to it, as long as you can be sure it is deallocated (however you choose to define that term) when the function exits, then
    there's really nothing to worry about.

    I can imagine a few tests, though, that might be interesting. Like having
    a million or so blocks like this, and have each one jump out from the
    middle. And then you could keep track of how things are going by printing
    out the address of i (using printf and %p) and see if they are the same or different.

    Might be a fun thing to do on a rainy day...

    --
    "It does a lot of things half well and it's just a garbage heap of ideas that are
    mutually exclusive."

    - Ken Thompson, on C++ -

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bart@3:633/10 to All on Mon May 25 18:48:58 2026
    Subject: Re: The whole point of this NG is worrying about "UB" (Was: Using gotos with local variables in "extra" blocks: Does it get) deallocated?

    On 25/05/2026 18:23, Kenny McCormack wrote:
    In article <10v1vmr$1s757$7@dont-email.me>,
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
    ...
    Or, to put it another way, that, no, you can't rely on the compiler "doing >>> the right thing", if you've violated some obscure rule.

    ...but I think another post down-thread addresses the original question
    sufficiently.

    Agreed. I think I've got my answer.

    When you get right down to it, as long as you can be sure it is deallocated (however you choose to define that term) when the function exits, then there's really nothing to worry about.

    Not for simple variables. Unless they refer to some resource that needs freeing using the value of the variable. But this is just normal
    housekeeping in C.


    I can imagine a few tests, though, that might be interesting. Like having
    a million or so blocks like this, and have each one jump out from the
    middle. And then you could keep track of how things are going by printing out the address of i (using printf and %p) and see if they are the same or different.

    Obtaining the address of i forces it to be in memory rather than a
    register. Then, if you have a million nested blocks each declaring 'int
    i;' and using '&i', you will probably get a stack overflow at runtime,
    but it will probably fail to compile anyway (see below):.

    Might be a fun thing to do on a rainy day...

    Today's the hottest day of the year in the UK, so I tried a program like
    this:

    {int i=rand(); printf("%p\n", &i);
    {int i=rand(); printf("%p\n", &i);
    {int i=rand(); printf("%p\n", &i);
    }
    }
    }

    using N = 1000000 instead of 3. But I couldn't get it to compile:

    tcc crashed
    gcc 16 stopped after 20 seconds, but no EXE generated
    DMC After 20-30 seconds, errorcode -1073741571
    lccwin32 After a few seconds, errorcode -1073741571 also (?)
    bcc Immediate error "too many block levels"

    With a smaller N however, then you just get lots of different addresses
    since they are nested and their lifetimes overlap. With a version like this:

    {int i=rand(); printf("%p\n", &i);}
    {int i=rand(); printf("%p\n", &i);}
    {int i=rand(); printf("%p\n", &i);}

    Then the addresses are either all different still, or the same,
    depending on compiler and options.




    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Scott Lurndal@3:633/10 to All on Mon May 25 17:49:23 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <10v1jrr$35gqh$2@news.xmission.com>,
    Kenny McCormack <gazelle@shell.xmission.com> wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer >>discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and >>also on some of my own code, I got to wondering about the following code >>fragment:

    void foo(void) {
    /* stuff */
    { /* Enter an "extra" block */
    int i = 42; /* 'i' is allocated on the stack */
    /* stuff */
    if (someCond) goto OutOfHere;
    /* more stuff */
    } /* End of "extra" block */
    OutOfHere: puts("Got to OutOfHere");
    } /* End of foo() */

    Now suppose someCond is true and the branch is taken. Does the variable >>'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    The variable `i` will be deallocated, yes. But if the question
    is whether that happens immediately after the `goto` or not,
    then it's that's a different question.

    The standard says that if a variable with "automatic storage
    duration" is not a VLA (which describes `i` in this case), then
    the lifetime of the object ends when "execution of that block
    ends in any way" (sec 6.2.4 of the various standards; para 6 in
    n3220).

    Here, "lifetime" is defined as, "the portion of program
    execution during which storage is guaranteed to be reserved for
    it."

    So whether or not the storage is _immediately_ reclaimed is
    another matter; it may be immediately deallocated after exiting
    the block, or when the function returns, or some other time.

    Note that in most/all "scripting" languages, this code pattern would be a >>big no-no, and if you did it enough times, it will blow up the program.

    Huh. Which languages?

    Note, BTW, that we could make this issue go away by putting OutOfHere a >>line earlier - i.e., inside the "extra" block - but then we'd run into >>Bart's issue (i.e., we'd have to put an extra ';' after the label).

    It actually doesn't change the issue at all; whether "execution"
    of the block ends due to a `goto` out of it or reaching the end
    of the block as written is irrelevant: it'll be deallocated
    regardless. But whether that happens immediately or not is
    another matter.

    Assuming a stack-based implementation, I'd assume most compilers
    would deallocate it when the enclosing function returns.

    In believe in most cases, the compiler simply adds the required
    storage space for all variables defined in inner-blocks to the
    initial stack allocation on function entry. Which is all "deallocated"
    when the function returns. Indeed, I believe that the storage
    reserved for inner block variables can be repurposed and used
    in subsequent inner-blocks that have local variables in the same
    function.

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Pierre Asselin@3:633/10 to All on Mon May 25 19:52:03 2026
    Subject: Variables in inner blocks (was: Using gotos with local variables in "extra" blocks: Does it get deallocated?)

    Scott Lurndal <scott@slp53.sl.home> wrote:

    In believe in most cases, the compiler simply adds the required
    storage space for all variables defined in inner-blocks to the
    initial stack allocation on function entry. Which is all "deallocated"
    when the function returns.

    Yeah, I believe so. But in some code I was working on back in 2009,
    I had the following pattern in a function that called itself
    recursively:

    static void fou(struct something *x)
    {
    struct something *y[3];
    {
    /* declare many more variables */
    /* do things that fill the y[] array of pointers */
    }
    if(y[0]) fou(y[0]);
    if(y[1]) fou(y[1]);
    if(y[2]) fou(y[2]);
    }

    I put most of the function body in an inner block, hoping that the
    inner variables would be deallocated before the recursive phase
    and that stack usage would be reduced.

    I don't think my micro-optimization worked. It didn't matter,
    even with the larger stack frame the function never came close
    to blowing up.

    (It was a part of a 3D tetrahedral mesher. I'll have to try
    with a small self-contained example and look at the assembler.)

    --
    pa at panix dot com

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Dan Cross@3:633/10 to All on Tue May 26 14:13:17 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    In article <DY%QR.370372$gO1.309583@fx14.iad>,
    Scott Lurndal <slp53@pacbell.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <10v1jrr$35gqh$2@news.xmission.com>,
    Kenny McCormack <gazelle@shell.xmission.com> wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer >>>discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and >>>also on some of my own code, I got to wondering about the following code >>>fragment:

    void foo(void) {
    /* stuff */
    { /* Enter an "extra" block */
    int i = 42; /* 'i' is allocated on the stack */
    /* stuff */
    if (someCond) goto OutOfHere;
    /* more stuff */
    } /* End of "extra" block */
    OutOfHere: puts("Got to OutOfHere");
    } /* End of foo() */

    Now suppose someCond is true and the branch is taken. Does the variable >>>'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    The variable `i` will be deallocated, yes. But if the question
    is whether that happens immediately after the `goto` or not,
    then it's that's a different question.

    The standard says that if a variable with "automatic storage
    duration" is not a VLA (which describes `i` in this case), then
    the lifetime of the object ends when "execution of that block
    ends in any way" (sec 6.2.4 of the various standards; para 6 in
    n3220).

    Here, "lifetime" is defined as, "the portion of program
    execution during which storage is guaranteed to be reserved for
    it."

    So whether or not the storage is _immediately_ reclaimed is
    another matter; it may be immediately deallocated after exiting
    the block, or when the function returns, or some other time.

    Note that in most/all "scripting" languages, this code pattern would be a >>>big no-no, and if you did it enough times, it will blow up the program.

    Huh. Which languages?

    Note, BTW, that we could make this issue go away by putting OutOfHere a >>>line earlier - i.e., inside the "extra" block - but then we'd run into >>>Bart's issue (i.e., we'd have to put an extra ';' after the label).

    It actually doesn't change the issue at all; whether "execution"
    of the block ends due to a `goto` out of it or reaching the end
    of the block as written is irrelevant: it'll be deallocated
    regardless. But whether that happens immediately or not is
    another matter.

    Assuming a stack-based implementation, I'd assume most compilers
    would deallocate it when the enclosing function returns.

    In believe in most cases, the compiler simply adds the required
    storage space for all variables defined in inner-blocks to the
    initial stack allocation on function entry. Which is all "deallocated"
    when the function returns. Indeed, I believe that the storage
    reserved for inner block variables can be repurposed and used
    in subsequent inner-blocks that have local variables in the same
    function.

    Almost certainly, yes. Of course there are some exceptions, but
    the vast bulk of real-world implementations will use a stack and
    likely do exactly what you just said. And on exit, deallocating
    a stack frame may as simple as a single instruction.

    - Dan C.


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Scott Lurndal@3:633/10 to All on Tue May 26 17:10:38 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <DY%QR.370372$gO1.309583@fx14.iad>,
    Scott Lurndal <slp53@pacbell.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <10v1jrr$35gqh$2@news.xmission.com>,
    Kenny McCormack <gazelle@shell.xmission.com> wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer >>>>discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and >>>>also on some of my own code, I got to wondering about the following code >>>>fragment:

    void foo(void) {
    /* stuff */
    { /* Enter an "extra" block */
    int i = 42; /* 'i' is allocated on the stack */
    /* stuff */
    if (someCond) goto OutOfHere;
    /* more stuff */
    } /* End of "extra" block */
    OutOfHere: puts("Got to OutOfHere");
    } /* End of foo() */

    Now suppose someCond is true and the branch is taken. Does the variable >>>>'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    The variable `i` will be deallocated, yes. But if the question
    is whether that happens immediately after the `goto` or not,
    then it's that's a different question.

    The standard says that if a variable with "automatic storage
    duration" is not a VLA (which describes `i` in this case), then
    the lifetime of the object ends when "execution of that block
    ends in any way" (sec 6.2.4 of the various standards; para 6 in
    n3220).

    Here, "lifetime" is defined as, "the portion of program
    execution during which storage is guaranteed to be reserved for
    it."

    So whether or not the storage is _immediately_ reclaimed is
    another matter; it may be immediately deallocated after exiting
    the block, or when the function returns, or some other time.

    Note that in most/all "scripting" languages, this code pattern would be a >>>>big no-no, and if you did it enough times, it will blow up the program.

    Huh. Which languages?

    Note, BTW, that we could make this issue go away by putting OutOfHere a >>>>line earlier - i.e., inside the "extra" block - but then we'd run into >>>>Bart's issue (i.e., we'd have to put an extra ';' after the label).

    It actually doesn't change the issue at all; whether "execution"
    of the block ends due to a `goto` out of it or reaching the end
    of the block as written is irrelevant: it'll be deallocated
    regardless. But whether that happens immediately or not is
    another matter.

    Assuming a stack-based implementation, I'd assume most compilers
    would deallocate it when the enclosing function returns.

    In believe in most cases, the compiler simply adds the required
    storage space for all variables defined in inner-blocks to the
    initial stack allocation on function entry. Which is all "deallocated"
    when the function returns. Indeed, I believe that the storage
    reserved for inner block variables can be repurposed and used
    in subsequent inner-blocks that have local variables in the same
    function.

    Almost certainly, yes. Of course there are some exceptions, but
    the vast bulk of real-world implementations will use a stack and
    likely do exactly what you just said. And on exit, deallocating
    a stack frame may as simple as a single instruction.

    Experimenting with gcc (4.8.3, 14.2.1) shows that the
    stack layout depends on -O.

    int fff(int yyy, int xxx)
    {
    int ab = yyy + xxx;

    {
    int bb;
    printf("%p\n", &bb);
    }

    {
    int bc;
    printf("%p\n", &bc);
    }

    printf("%p\n", &ab);

    return 0;
    }

    int main()
    {
    fff(1,2);
    }

    --------------
    Without -O:
    $ /tmp/a
    0x7ffe40c2f338
    0x7ffe40c2f334
    0x7ffe40c2f33c

    With -O3:
    $ /tmp/a
    0x7ffe21e5833c
    0x7ffe21e5833c
    0x7ffe21e58330

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Tue May 26 20:31:12 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 26/05/2026 19:10, Scott Lurndal wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <DY%QR.370372$gO1.309583@fx14.iad>,
    Scott Lurndal <slp53@pacbell.net> wrote:
    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <10v1jrr$35gqh$2@news.xmission.com>,
    Kenny McCormack <gazelle@shell.xmission.com> wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and >>>>> also on some of my own code, I got to wondering about the following code >>>>> fragment:

    void foo(void) {
    /* stuff */
    { /* Enter an "extra" block */
    int i = 42; /* 'i' is allocated on the stack */
    /* stuff */
    if (someCond) goto OutOfHere;
    /* more stuff */
    } /* End of "extra" block */
    OutOfHere: puts("Got to OutOfHere");
    } /* End of foo() */

    Now suppose someCond is true and the branch is taken. Does the variable >>>>> 'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    The variable `i` will be deallocated, yes. But if the question
    is whether that happens immediately after the `goto` or not,
    then it's that's a different question.

    The standard says that if a variable with "automatic storage
    duration" is not a VLA (which describes `i` in this case), then
    the lifetime of the object ends when "execution of that block
    ends in any way" (sec 6.2.4 of the various standards; para 6 in
    n3220).

    Here, "lifetime" is defined as, "the portion of program
    execution during which storage is guaranteed to be reserved for
    it."

    So whether or not the storage is _immediately_ reclaimed is
    another matter; it may be immediately deallocated after exiting
    the block, or when the function returns, or some other time.

    Note that in most/all "scripting" languages, this code pattern would be a >>>>> big no-no, and if you did it enough times, it will blow up the program. >>>>
    Huh. Which languages?

    Note, BTW, that we could make this issue go away by putting OutOfHere a >>>>> line earlier - i.e., inside the "extra" block - but then we'd run into >>>>> Bart's issue (i.e., we'd have to put an extra ';' after the label).

    It actually doesn't change the issue at all; whether "execution"
    of the block ends due to a `goto` out of it or reaching the end
    of the block as written is irrelevant: it'll be deallocated
    regardless. But whether that happens immediately or not is
    another matter.

    Assuming a stack-based implementation, I'd assume most compilers
    would deallocate it when the enclosing function returns.

    In believe in most cases, the compiler simply adds the required
    storage space for all variables defined in inner-blocks to the
    initial stack allocation on function entry. Which is all "deallocated"
    when the function returns. Indeed, I believe that the storage
    reserved for inner block variables can be repurposed and used
    in subsequent inner-blocks that have local variables in the same
    function.

    Almost certainly, yes. Of course there are some exceptions, but
    the vast bulk of real-world implementations will use a stack and
    likely do exactly what you just said. And on exit, deallocating
    a stack frame may as simple as a single instruction.

    Experimenting with gcc (4.8.3, 14.2.1) shows that the
    stack layout depends on -O.


    One of the reasons for using -O0 is debugging, especially with weaker debuggers. As gcc gives every variable its own stack slot, these remain consistent throughout the function, making it easier to see. When
    registers and stack slots are re-used it becomes harder for the debugger
    (and the person doing the debugging) to view the local variables at
    different points in the function.


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lynn McGuire@3:633/10 to All on Tue May 26 17:14:45 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 5/25/2026 8:46 AM, Kenny McCormack wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and
    also on some of my own code, I got to wondering about the following code fragment:

    void foo(void) {
    /* stuff */
    { /* Enter an "extra" block */
    int i = 42; /* 'i' is allocated on the stack */
    /* stuff */
    if (someCond) goto OutOfHere;
    /* more stuff */
    } /* End of "extra" block */
    OutOfHere: puts("Got to OutOfHere");
    } /* End of foo() */

    Now suppose someCond is true and the branch is taken. Does the variable
    'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    Note that in most/all "scripting" languages, this code pattern would be a
    big no-no, and if you did it enough times, it will blow up the program.

    Note, BTW, that we could make this issue go away by putting OutOfHere a
    line earlier - i.e., inside the "extra" block - but then we'd run into
    Bart's issue (i.e., we'd have to put an extra ';' after the label)

    What is the dreaded s word, scripting ?

    Lynn

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Dan Cross@3:633/10 to All on Wed May 27 00:23:23 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    In article <10v560l$2csvm$1@dont-email.me>,
    Lynn McGuire <lynnmcguire5@gmail.com> wrote:
    On 5/25/2026 8:46 AM, Kenny McCormack wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.
    [snip]

    What is the dreaded s word, scripting ?

    I think it's "stack". The C standard doesn't make any reference
    to call stacks or stack allocation, AFAIK. However, in practice
    most systems use one; there are a handful of exceptions however.

    - Dan C.


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Kenny McCormack@3:633/10 to All on Wed May 27 02:09:23 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    In article <10v5dhr$5vi$1@reader1.panix.com>,
    Dan Cross <cross@spitfire.i.gajendra.net> wrote:
    In article <10v560l$2csvm$1@dont-email.me>,
    Lynn McGuire <lynnmcguire5@gmail.com> wrote:
    On 5/25/2026 8:46 AM, Kenny McCormack wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.
    [snip]

    What is the dreaded s word, scripting ?

    I think it's "stack". The C standard doesn't make any reference
    to call stacks or stack allocation, AFAIK. However, in practice
    most systems use one; there are a handful of exceptions however.

    Yes, and whenever anyone uses the 's word' in this NG, certain posters go
    very, shall we say, and putting it charitably, non-linear.

    --
    (Cruz certainly has an odd face) ... it looks like someone sewed pieces of a waterlogged Reagan mask together at gunpoint ...

    http://www.rollingstone.com/politics/news/how-america-made-donald-trump-unstoppable-20160224

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lynn McGuire@3:633/10 to All on Tue May 26 22:51:02 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 5/26/2026 7:23 PM, Dan Cross wrote:
    In article <10v560l$2csvm$1@dont-email.me>,
    Lynn McGuire <lynnmcguire5@gmail.com> wrote:
    On 5/25/2026 8:46 AM, Kenny McCormack wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.
    [snip]

    What is the dreaded s word, scripting ?

    I think it's "stack". The C standard doesn't make any reference
    to call stacks or stack allocation, AFAIK. However, in practice
    most systems use one; there are a handful of exceptions however.

    - Dan C.

    I used to write assembly language on IBM 370s and Fortran on IBM 3090s.
    No stack that I know of. My prof in my IBM 370 assembly language class
    taught us how to create a simulated stack.

    I have no idea about modern IBM mainframes. I don't even know what
    their model number is.

    Lynn


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Wed May 27 04:46:57 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On Tue, 26 May 2026 22:51:02 -0500, Lynn McGuire wrote:

    I used to write assembly language on IBM 370s and Fortran on IBM
    3090s. No stack that I know of.

    IBM architectures never had a hardware stack. The POWER/PowerPC ABI
    defines a stack, but that?s purely a software convention.

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From David Brown@3:633/10 to All on Wed May 27 09:21:24 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 27/05/2026 06:46, Lawrence D?Oliveiro wrote:
    On Tue, 26 May 2026 22:51:02 -0500, Lynn McGuire wrote:

    I used to write assembly language on IBM 370s and Fortran on IBM
    3090s. No stack that I know of.

    IBM architectures never had a hardware stack. The POWER/PowerPC ABI
    defines a stack, but that?s purely a software convention.

    PowerPC can use any register as a stack pointer (in that they support appropriate load and store with pre/post increment/decrement operations
    needed for efficient usage, along with reg + offset addressing), and
    does not give preference to any of them. Thus the choice of register
    for the stack pointer was basically arbitrary when the ABI was planned.
    That's quite common for RISC architectures. (It also means you can
    easily support languages that have more than one stack, like Forth.)

    I think the only systems this century that don't have a stack, or have
    only very limited stacks, are some small 8-bit microcontrollers. There
    are a number of such devices where the return stack is fixed size
    dedicated memory, separate from main ram. And there are several which
    have a stack for call/return and have push/pop instructions (often just
    for the one accumulator register), but which are missing any kind of
    SP+offset addressing mode needed for practical use of a stack frame for
    data. On these devices, C compilers generally do whole-program analysis
    of variable usage and allocate fixed memory addresses for function local variables, multiplexing the addresses when usage does not overlap. It
    is only if you have a recursive or re-entrant function that some kind of
    stack solution is needed.


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Dan Cross@3:633/10 to All on Wed May 27 12:40:33 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    In article <10v5pn8$2guem$1@dont-email.me>,
    Lynn McGuire <lynnmcguire5@gmail.com> wrote:
    On 5/26/2026 7:23 PM, Dan Cross wrote:
    In article <10v560l$2csvm$1@dont-email.me>,
    Lynn McGuire <lynnmcguire5@gmail.com> wrote:
    On 5/25/2026 8:46 AM, Kenny McCormack wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.
    [snip]

    What is the dreaded s word, scripting ?

    I think it's "stack". The C standard doesn't make any reference
    to call stacks or stack allocation, AFAIK. However, in practice
    most systems use one; there are a handful of exceptions however.

    I used to write assembly language on IBM 370s and Fortran on IBM 3090s.
    No stack that I know of. My prof in my IBM 370 assembly language class >taught us how to create a simulated stack.

    I have no idea about modern IBM mainframes. I don't even know what
    their model number is.

    Mainframes are the primary example I was thinking of. Btw, the
    latest incarnation of IBM's S/360/370/390 line is called
    "z/Architecture" and the z17 is the current top-of-the-line
    offering from Big Blue.

    On older version of that ISA, function (nee procedure,
    subroutine, etc) calls are made by instructions that take a GP
    register operand that holds the address of the next instruction;
    that "link register" thus holds the function return address, and
    there is a "store multiple" instruction to write one or more
    registers to memory (excuse me, "storage" in IBM parlance); one
    presumes that a program (or a langauge; I'm assuming assembler
    here) adopts some convention for a designated link register, and
    writes it into a software-managed "save area" of memory on entry
    or before itself making a call. This is almost RISC-like, and
    unlike (say) x86 that automatically pushes the return address
    onto a hardware stack that is pointed to by a dedicated "stack
    pointer" register.

    I believe traditionally, entry into a function (nee procedure,
    subroutine, etc) involved allocating the temporary working space
    required for that subroutine, and adding that to a linked list
    of such allocations, as opposed to operating on a window into a
    single, larger region. But I see no reason a program couldn't
    allocate a large region and use another register as a "stack"
    pointer into that region in a more conventional way. If one
    were feeling bold, one could even take a third register to use
    as a frame pointer. Idly, I wonder if one should refer to the
    more common kind of stack use as the more "conventional" way,
    since this mechanism in the lizard brain of z/arch predates most
    architectures in use today by a couple of decades.

    That aside, poking around briefly it looks like IBM supports
    "language environments" that seem roughly like runtimes and ABIs
    for, well, specific languages. One presumes different languages
    might do things in ways similar to other machines. I don't have
    time right now to look in more detail, but I see some indicators
    that this may be the case, and a few documents describing
    hardware mention stacks, so perhaps they've added some support
    in the 64-bit ISA.

    - Dan C.


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Wed May 27 15:33:46 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    Kenny McCormack pisze:
    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and
    also on some of my own code, I got to wondering about the following code fragment:

    void foo(void) {
    /* stuff */
    { /* Enter an "extra" block */
    int i = 42; /* 'i' is allocated on the stack */
    /* stuff */
    if (someCond) goto OutOfHere;
    /* more stuff */
    } /* End of "extra" block */
    OutOfHere: puts("Got to OutOfHere");
    } /* End of foo() */

    Now suppose someCond is true and the branch is taken. Does the variable
    'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    Note that in most/all "scripting" languages, this code pattern would be a
    big no-no, and if you did it enough times, it will blow up the program.

    Note, BTW, that we could make this issue go away by putting OutOfHere a
    line earlier - i.e., inside the "extra" block - but then we'd run into
    Bart's issue (i.e., we'd have to put an extra ';' after the label).


    its not answer to thsi question but imo nested scopes in functions
    practicaly imo have rather no to much big sense (imo for example fact
    that afair if and for loop have its on scope is most probably an error/mistake..is and loops are so called lightweight control structures
    not searate material scopes

    what would have more sense is local scope for few functions sharing
    one variable when more distant functions would not see it


    even so called file scope would be probably nice

    //main.c

    gloabal scope int x;
    file scope int y;

    if you want some thing having global (module) scope denot its as
    global if you want file scope denote it as file scope (included files
    and the ones that include it shouldnt see it)

    there could also be more aleborated scopes defined but i not thinked
    about some real usability of this yet.. what language should care
    should be for sure locality - to spare code jumping to minium
    (to zero for the best) and also probably no 'pollution' this is
    scopes should be as they are needed not such that in given X place you
    see 5 hundred of symbols you wouldnt need

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Scott Lurndal@3:633/10 to All on Wed May 27 14:48:31 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    cross@spitfire.i.gajendra.net (Dan Cross) writes:
    In article <10v5pn8$2guem$1@dont-email.me>,
    Lynn McGuire <lynnmcguire5@gmail.com> wrote:
    On 5/26/2026 7:23 PM, Dan Cross wrote:
    In article <10v560l$2csvm$1@dont-email.me>,
    Lynn McGuire <lynnmcguire5@gmail.com> wrote:
    On 5/25/2026 8:46 AM, Kenny McCormack wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.
    [snip]

    What is the dreaded s word, scripting ?

    I think it's "stack". The C standard doesn't make any reference
    to call stacks or stack allocation, AFAIK. However, in practice
    most systems use one; there are a handful of exceptions however.

    I used to write assembly language on IBM 370s and Fortran on IBM 3090s.
    No stack that I know of. My prof in my IBM 370 assembly language class >>taught us how to create a simulated stack.

    I have no idea about modern IBM mainframes. I don't even know what
    their model number is.

    Mainframes are the primary example I was thinking of. Btw, the
    latest incarnation of IBM's S/360/370/390 line is called
    "z/Architecture" and the z17 is the current top-of-the-line
    offering from Big Blue.

    It is worth noting that all the Burroughs mainframes
    had hardware stacks, in fact the stack was core[*] to the large
    systems (B5500 and successors).

    [*] pun intended

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bart@3:633/10 to All on Wed May 27 17:18:30 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 27/05/2026 14:33, fir wrote:
    Kenny McCormack pisze:
    Trigger Warning: This post contains the dreaded "s word".˙ Viewer
    discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and
    also on some of my own code, I got to wondering about the following code
    fragment:

    ˙˙˙˙ void foo(void) {
    ˙˙˙˙/* stuff */
    ˙˙˙˙{˙˙˙ /* Enter an "extra" block */
    ˙˙˙˙int i = 42;˙˙˙ /* 'i' is allocated on the stack */
    ˙˙˙˙/* stuff */
    ˙˙˙˙if (someCond) goto OutOfHere;
    ˙˙˙˙/* more stuff */
    ˙˙˙˙}˙˙˙ /* End of "extra" block */
    ˙˙˙˙ OutOfHere: puts("Got to OutOfHere");
    ˙˙˙˙ }˙˙˙ /* End of foo() */

    Now suppose someCond is true and the branch is taken.˙ Does the variable
    'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    Note that in most/all "scripting" languages, this code pattern would be a
    big no-no, and if you did it enough times, it will blow up the program.

    Note, BTW, that we could make this issue go away by putting OutOfHere a
    line earlier - i.e., inside the "extra" block - but then we'd run into
    Bart's issue (i.e., we'd have to put an extra ';' after the label).


    its not answer to thsi question but imo nested scopes in functions practicaly imo have rather no to much big sense (imo for example fact
    that afair if and for loop have its on scope is most probably an error/mistake..is and loops are so called lightweight control structures
    not searate material scopes

    I don't know why so many functions make such a big deal of this.

    As it is, C has one scope outside a function, and an UNLIMITED number
    inside a function, for a language which averages 3 locals per function.

    You can this do at file scope:

    static int abc // local to each file

    or:

    int abc; // exported or imported

    Each FILE can only contain one possible definition or declaration 'abc'.

    But every function in every file can define an unlimited number of
    definitions of 'abc' in multiple block scopes.

    The priorities are back to front!

    In languages with namespaces and modules, you can have 100 modules each exporting a different 'abc', and each can be accessed from any other module.


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Wed May 27 18:51:35 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    Bart pisze:
    On 27/05/2026 14:33, fir wrote:
    Kenny McCormack pisze:
    Trigger Warning: This post contains the dreaded "s word".˙ Viewer
    discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and
    also on some of my own code, I got to wondering about the following code >>> fragment:

    ˙˙˙˙ void foo(void) {
    ˙˙˙˙/* stuff */
    ˙˙˙˙{˙˙˙ /* Enter an "extra" block */
    ˙˙˙˙int i = 42;˙˙˙ /* 'i' is allocated on the stack */
    ˙˙˙˙/* stuff */
    ˙˙˙˙if (someCond) goto OutOfHere;
    ˙˙˙˙/* more stuff */
    ˙˙˙˙}˙˙˙ /* End of "extra" block */
    ˙˙˙˙ OutOfHere: puts("Got to OutOfHere");
    ˙˙˙˙ }˙˙˙ /* End of foo() */

    Now suppose someCond is true and the branch is taken.˙ Does the variable >>> 'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    Note that in most/all "scripting" languages, this code pattern would
    be a
    big no-no, and if you did it enough times, it will blow up the program.

    Note, BTW, that we could make this issue go away by putting OutOfHere a
    line earlier - i.e., inside the "extra" block - but then we'd run into
    Bart's issue (i.e., we'd have to put an extra ';' after the label).


    its not answer to thsi question but imo nested scopes in functions
    practicaly imo have rather no to much big sense (imo for example fact
    that afair if and for loop have its on scope is most probably an
    error/mistake..is and loops are so called lightweight control
    structures not searate material scopes

    I don't know why so many functions make such a big deal of this.

    As it is, C has one scope outside a function, and an UNLIMITED number
    inside a function, for a language which averages 3 locals per function.

    You can this do at file scope:

    ˙ static int abc˙˙˙˙˙˙˙ // local to each file

    or:

    ˙ int abc;˙˙˙˙˙˙˙˙˙˙˙˙˙ // exported or imported

    Each FILE can only contain one possible definition or declaration 'abc'.

    But every function in every file can define an unlimited number of definitions of 'abc' in multiple block scopes.

    The priorities are back to front!

    In languages with namespaces and modules, you can have 100 modules each exporting a different 'abc', and each can be accessed from any other
    module.


    ye i forgot about this static, so you hae 3 scopes, [1] local to
    function (well yet this [2] local to block afair (so 4) which in most
    cases is imo probably not needed/confusing..[3] module internal/global interna; [4] module external/global external (as far as i remember, in
    fact i was heavy break in coding)

    i mean this may be a consequence of fact that c comes from 1970 when
    modules was small (i thing whole 20 years like 1970-1990 was like mostly
    8 bit era)

    later before AI i was able to code 9k lines a month (all i include in
    one by includes of .c files and this compiles about 1s so no need to
    divide and slow my work...after AI era the speedup of coding increased
    - i not measured it but it seem to be like 4x maybe 5x speedup (thus
    40-50k lines a month...maybe more maybe less..but still 40k lines source compiles fast

    and now is different situation and you got many logical files in one
    big scope so situation is new imo and at least something like real file
    scope could be handy imo... thise name "namespace" i rather dislike but
    if some could be able to define scopes it would be something like
    namespace probably (though i dont know what it could be

    for example some may think if now you use include .c files (as far as i remember you and i prefer this way) then some could say those includes
    form a tree of includes (cos you can inlude in shallow but you may
    include in includes etc - if so there are 3 options of file scope

    1) this file only scope
    2) this file and files included (tt is here and down)
    3) this file and file who includes it (its here and upp)

    not saying this would be usefull but there is such possibility

    splitting code on files is imo quite practical and im not sure its
    good that c allows you to open { in one file and close it } in included
    one.. this is very raw

    if treating files more seriously you could name then np

    file main; // names this file

    and maybe such files could even be in some way better than modules in
    some way (eventually there could be mechanism to treat file as module externally








    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Wed May 27 18:56:18 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    fir pisze:
    Bart pisze:
    On 27/05/2026 14:33, fir wrote:
    Kenny McCormack pisze:
    Trigger Warning: This post contains the dreaded "s word".˙ Viewer
    discretion advised.

    Based on some recent threads (mostly, the Bart vs. The World ones), and >>>> also on some of my own code, I got to wondering about the following
    code
    fragment:

    ˙˙˙˙ void foo(void) {
    ˙˙˙˙/* stuff */
    ˙˙˙˙{˙˙˙ /* Enter an "extra" block */
    ˙˙˙˙int i = 42;˙˙˙ /* 'i' is allocated on the stack */
    ˙˙˙˙/* stuff */
    ˙˙˙˙if (someCond) goto OutOfHere;
    ˙˙˙˙/* more stuff */
    ˙˙˙˙}˙˙˙ /* End of "extra" block */
    ˙˙˙˙ OutOfHere: puts("Got to OutOfHere");
    ˙˙˙˙ }˙˙˙ /* End of foo() */

    Now suppose someCond is true and the branch is taken.˙ Does the
    variable
    'i' get deallocated (i.e., the stack pointer re-adjusted) ?

    Is this guaranteed to work?

    Note that in most/all "scripting" languages, this code pattern would
    be a
    big no-no, and if you did it enough times, it will blow up the program. >>>>
    Note, BTW, that we could make this issue go away by putting OutOfHere a >>>> line earlier - i.e., inside the "extra" block - but then we'd run into >>>> Bart's issue (i.e., we'd have to put an extra ';' after the label).


    its not answer to thsi question but imo nested scopes in functions
    practicaly imo have rather no to much big sense (imo for example fact
    that afair if and for loop have its on scope is most probably an
    error/mistake..is and loops are so called lightweight control
    structures not searate material scopes

    I don't know why so many functions make such a big deal of this.

    As it is, C has one scope outside a function, and an UNLIMITED number
    inside a function, for a language which averages 3 locals per function.

    You can this do at file scope:

    ˙˙ static int abc˙˙˙˙˙˙˙ // local to each file

    or:

    ˙˙ int abc;˙˙˙˙˙˙˙˙˙˙˙˙˙ // exported or imported

    Each FILE can only contain one possible definition or declaration 'abc'.

    But every function in every file can define an unlimited number of
    definitions of 'abc' in multiple block scopes.

    The priorities are back to front!

    In languages with namespaces and modules, you can have 100 modules
    each exporting a different 'abc', and each can be accessed from any
    other module.


    ye i forgot about this static, so you hae 3 scopes, [1] local to
    function (well yet this [2] local to block afair (so 4) which in most
    cases is imo probably not needed/confusing..[3] module internal/global interna; [4] module external/global external (as far as i remember, in
    fact i was heavy break in coding)

    i mean this may be a consequence of fact that c comes from 1970 when
    modules was small (i thing whole 20 years like 1970-1990 was like mostly
    8 bit era)

    later before AI i was able to code 9k lines a month (all i include in
    one by includes of .c files and this compiles about 1s so no need to
    divide and slow my work...after AI era the speedup of coding increased
    - i not measured it but it seem to be like 4x maybe 5x speedup (thus
    40-50k lines a month...maybe more maybe less..but still 40k lines source compiles fast

    and now is different situation and you got many logical files in one
    big scope so situation is new imo and at least something like real file
    scope could be handy imo... thise name "namespace" i rather dislike but
    if some could be able to define scopes it would be something like
    namespace probably (though i dont know what it could be

    for example some may think if now you use include .c files (as far as i remember you and i prefer this way) then some could say those includes
    form a tree of includes (cos you can inlude in shallow but you may
    include in includes etc - if so there are 3 options of file scope

    1) this file only scope
    2) this file and files included (tt is here and down)
    3) this file and file who includes it (its here and upp)

    well tehnically yet there ate two options
    4) this file sope and files up and down
    5) all files

    6) well yet something named like scope [name files who sees it]


    not saying this would be usefull but there is such possibility

    splitting code on files is imo quite practical and im not sure its
    good that c allows you to open { in one file and close it } in included one.. this is very raw

    if treating files more seriously you could name then np

    file main;˙ // names this file

    and maybe such files could even be in some way better than modules in
    some way (eventually there could be mechanism to treat file as module externally









    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Wed May 27 13:32:00 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 5/26/2026 8:51 PM, Lynn McGuire wrote:
    On 5/26/2026 7:23 PM, Dan Cross wrote:
    In article <10v560l$2csvm$1@dont-email.me>,
    Lynn McGuire˙ <lynnmcguire5@gmail.com> wrote:
    On 5/25/2026 8:46 AM, Kenny McCormack wrote:
    Trigger Warning: This post contains the dreaded "s word".˙ Viewer
    discretion advised.
    [snip]

    What is the dreaded s word, scripting ?

    I think it's "stack".˙ The C standard doesn't make any reference
    to call stacks or stack allocation, AFAIK.˙ However, in practice
    most systems use one; there are a handful of exceptions however.

    ˙˙˙˙- Dan C.

    I used to write assembly language on IBM 370s and Fortran on IBM 3090s.
    No stack that I know of.˙ My prof in my IBM 370 assembly language class taught us how to create a simulated stack.

    Fwiw, that reminds me of making a stack for recursion in pure AppleSoft
    BASIC. It was pretty fun:
    _______________________
    100 REM ct_vfield_applesoft_basic
    110 HOME
    120 HGR: HCOLOR = 3: VTAB 22
    130 PRINT "ct_vfield_applesoft_basic"
    140 GOSUB 1000
    150 GOSUB 3000
    160 SP = 0
    170 RS(SP, 0) = 0
    180 RS(SP, 1) = -1
    190 RS(SP, 2) = 0
    200 RS(SP, 3) = 1
    210 RS(SP, 4) = 0
    220 GOSUB 8000
    230 V1(1) = 0: V1(2) = 0: V1(3) = 1: V1(4) = 128
    240 GOSUB 6000
    245 PRINT "Chris Thomasson's Koch Complete!"
    250 END

    1000 REM ct_init
    1010 PRINT "ct_init"
    1020 DIM A0(6)
    1030 DIM V0(4)
    1040 DIM V1(4)
    1050 DIM V2(4)
    1060 DIM V3(4)
    1070 DIM V4(4)
    1080 DIM V5(4)
    1090 RN = 3
    1100 DIM RS(RN, 16)
    1110 GOSUB 2000
    1120 RETURN

    2000 REM ct_init_plane
    2010 PRINT "ct_init_plane"
    2020 A0(1) = 279: REM m_plane.m_width
    2030 A0(2) = 191: REM m_plane.m_height
    2040 A0(3) = 0.0126106: REM m_plane.m_xstep
    2050 A0(4) = 0.0126316: REM m_plane.m_ystep
    2060 A0(5) = -1.75288: REM m_plane.m_axes.m_xmin
    2070 A0(6) = 1.2: REM m_plane.m_axes.m_ymax
    2080 RETURN

    3000 REM ct_display_plane
    3010 PRINT "ct_display_plane"
    3020 FOR I0 = 1 TO 6
    3030 PRINT "A0("; I0; ") = " A0(I0)
    3040 NEXT I0
    3050 RETURN

    4000 REM ct_project_point
    4010 REM PRINT "ct_project_point"
    4020 V0(3) = (V0(1) - A0(5)) / A0(3)
    4030 V0(4) = (A0(6) - V0(2)) / A0(4)
    4040 IF V0(3) < 0 THEN V0(3) = INT(V0(3) - .5)
    4050 IF V0(3) >= 0 THEN V0(3) = INT(V0(3) + .5)
    4060 IF V0(4) < 0 THEN V0(4) = INT(V0(4) - .5)
    4070 IF V0(4) >= 0 THEN V0(4) = INT(V0(4) + .5)
    4080 RETURN

    5000 REM ct_plot_point
    5010 REM PRINT "ct_plot_point"
    5020 GOSUB 4000
    5030 IF V0(3) > -1 AND V0(3) <= A0(1) AND V0(4) > -1 AND V0(4) <=
    A0(2) THEN HPLOT V0(3), V0(4)
    5040 RETURN

    6000 REM ct_plot_circle
    6010 PRINT "ct_plot_circle"
    6020 AB = 6.28318 / V1(4)
    6030 FOR I1 = 0 TO 6.28318 STEP AB
    6040 V0(1) = V1(1) + COS(I1) * V1(3)
    6050 V0(2) = V1(2) + SIN(I1) * V1(3)
    6060 GOSUB 5000
    6070 NEXT I1
    6080 RETURN

    7000 REM ct_plot_line
    7010 PRINT "ct_plot_line"
    7020 V0(1) = V5(1): V0(2) = V5(2)
    7030 GOSUB 4000
    7040 IF V0(3) < 0 THEN V0(3) = 0
    7050 IF V0(3) > A0(1) THEN V0(3) = A0(1)
    7060 IF V0(4) < 0 THEN V0(4) = 0
    7070 IF V0(4) > A0(2) THEN V0(4) = A0(2)
    7080 HPLOT V0(3), V0(4)
    7090 V0(1) = V5(3): V0(2) = V5(4)
    7100 GOSUB 4000
    7110 IF V0(3) < 0 THEN V0(3) = 0
    7120 IF V0(3) > A0(1) THEN V0(3) = A0(1)
    7130 IF V0(4) < 0 THEN V0(4) = 0
    7140 IF V0(4) > A0(2) THEN V0(4) = A0(2)
    7150 HPLOT TO V0(3), V0(4)
    7160 RETURN

    8000 REM ct_koch
    8010 IF RS(SP, 0) >= RN THEN RETURN
    8020 PRINT "ct_koch = "; RS(SP, 0); " "; RS(SP, 1); " "; RS(SP, 2);
    " "; RS(SP, 3); " "; RS(SP, 4)"
    8030 RS(SP, 5) = RS(SP, 3) - RS(SP, 1) : REM difx
    8040 RS(SP, 6) = RS(SP, 4) - RS(SP, 2) : REM dify
    8050 RS(SP, 7) = RS(SP, 1) + RS(SP, 5) / 2 : REM dify
    8060 RS(SP, 8) = RS(SP, 2) + RS(SP, 6) / 2 : REM dify
    8070 RS(SP, 9) = -RS(SP, 6) : REM perpx
    8080 RS(SP, 10) = RS(SP, 5) : REM perpy
    8090 RS(SP, 11) = RS(SP, 7) + RS(SP, 9) / 3 : REM tipx
    8100 RS(SP, 12) = RS(SP, 8) + RS(SP, 10) / 3 : REM tipy
    8110 RS(SP, 13) = RS(SP, 1) + RS(SP, 5) / 3 : REM k0x
    8120 RS(SP, 14) = RS(SP, 2) + RS(SP, 6) / 3 : REM k0y
    8130 RS(SP, 15) = RS(SP, 3) - RS(SP, 5) / 3 : REM k1x
    8140 RS(SP, 16) = RS(SP, 4) - RS(SP, 6) / 3 : REM k1y

    8145 IF RS(SP, 0) < RN - 1 GOTO 8230
    8150 V5(1) = RS(SP, 1): V5(2) = RS(SP, 2): V5(3) = RS(SP, 13): V5(4)
    = RS(SP, 14)
    8160 GOSUB 7000
    8170 V5(1) = RS(SP, 13): V5(2) = RS(SP, 14): V5(3) = RS(SP, 11):
    V5(4) = RS(SP, 12)
    8180 GOSUB 7000
    8190 V5(1) = RS(SP, 11): V5(2) = RS(SP, 12): V5(3) = RS(SP, 15):
    V5(4) = RS(SP, 16)
    8200 GOSUB 7000
    8210 V5(1) = RS(SP, 15): V5(2) = RS(SP, 16): V5(3) = RS(SP, 3):
    V5(4) = RS(SP, 4)
    8220 GOSUB 7000

    8230 REM line 0
    8240 SP = SP + 1
    8250 RS(SP, 0) = RS(SP - 1, 0) + 1
    8260 RS(SP, 1) = RS(SP - 1, 1)
    8270 RS(SP, 2) = RS(SP - 1, 2)
    8280 RS(SP, 3) = RS(SP - 1, 13)
    8290 RS(SP, 4) = RS(SP - 1, 14)
    8300 GOSUB 8000
    8310 SP = SP - 1
    8320 REM line 1
    8330 SP = SP + 1
    8340 RS(SP, 0) = RS(SP - 1, 0) + 1
    8350 RS(SP, 1) = RS(SP - 1, 13)
    8360 RS(SP, 2) = RS(SP - 1, 14)
    8370 RS(SP, 3) = RS(SP - 1, 11)
    8380 RS(SP, 4) = RS(SP - 1, 12)
    8390 GOSUB 8000
    8400 SP = SP - 1
    8410 REM line 2
    8420 SP = SP + 1
    8430 RS(SP, 0) = RS(SP - 1, 0) + 1
    8440 RS(SP, 1) = RS(SP - 1, 11)
    8450 RS(SP, 2) = RS(SP - 1, 12)
    8460 RS(SP, 3) = RS(SP - 1, 15)
    8470 RS(SP, 4) = RS(SP - 1, 16)
    8480 GOSUB 8000
    8490 SP = SP - 1
    8500 REM line 3
    8510 SP = SP + 1
    8520 RS(SP, 0) = RS(SP - 1, 0) + 1
    8530 RS(SP, 1) = RS(SP - 1, 15)
    8540 RS(SP, 2) = RS(SP - 1, 16)
    8550 RS(SP, 3) = RS(SP - 1, 3)
    8560 RS(SP, 4) = RS(SP - 1, 4)
    8570 GOSUB 8000
    8580 SP = SP - 1
    8590 RETURN
    _______________________

    [...]

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Wed May 27 13:39:51 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 5/27/2026 5:40 AM, Dan Cross wrote:
    In article <10v5pn8$2guem$1@dont-email.me>,
    Lynn McGuire <lynnmcguire5@gmail.com> wrote:
    On 5/26/2026 7:23 PM, Dan Cross wrote:
    In article <10v560l$2csvm$1@dont-email.me>,
    Lynn McGuire <lynnmcguire5@gmail.com> wrote:
    On 5/25/2026 8:46 AM, Kenny McCormack wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.
    [snip]

    What is the dreaded s word, scripting ?

    I think it's "stack". The C standard doesn't make any reference
    to call stacks or stack allocation, AFAIK. However, in practice
    most systems use one; there are a handful of exceptions however.

    I used to write assembly language on IBM 370s and Fortran on IBM 3090s.
    No stack that I know of. My prof in my IBM 370 assembly language class
    taught us how to create a simulated stack.

    I have no idea about modern IBM mainframes. I don't even know what
    their model number is.

    Mainframes are the primary example I was thinking of. Btw, the
    latest incarnation of IBM's S/360/370/390 line is called
    "z/Architecture" and the z17 is the current top-of-the-line
    offering from Big Blue.

    Fwiw, do you remember reading A-45 from:

    https://www.ibm.com/docs/en/module_1678991624569/pdf/SA22-7832-14.pdf

    I read that sucker many times back in the day. PLO was pretty fun.

    [...]

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Wed May 27 22:42:34 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On Wed, 27 May 2026 15:33:46 +0200, fir wrote:

    ... imo nested scopes in functions practicaly imo have rather no to
    much big sense (imo for example fact that afair if and for loop have
    its on scope is most probably an error/mistake..is and loops are so
    called lightweight control structures not searate material scopes

    What?s ?lightweight? about it is that the local variables (including particularly the loop variable, if any) can mostly reside in
    registers. This can mean no necessity for any special stack setup at
    all, to enter and exit those constructs.

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Wed May 27 17:04:17 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 5/27/2026 5:40 AM, Dan Cross wrote:
    [...]
    Mainframes are the primary example I was thinking of. Btw, the
    latest incarnation of IBM's S/360/370/390 line is called
    "z/Architecture" and the z17 is the current top-of-the-line
    offering from Big Blue.

    Fwiw, do you remember reading A-45 from:

    https://www.ibm.com/docs/en/module_1678991624569/pdf/SA22-7832-14.pdf

    I read that sucker many times back in the day. PLO was pretty fun.

    That's "z/Architecture Principles of Operation", a 2240-page PDF.
    Page A-45 is "Multiprogramming and Multiprocessing Examples".

    Next time you post a link like that, tell us what it is so somebody
    else doesn't have to do it for you.

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Chris M. Thomasson@3:633/10 to All on Wed May 27 18:16:07 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 5/27/2026 5:04 PM, Keith Thompson wrote:
    "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> writes:
    On 5/27/2026 5:40 AM, Dan Cross wrote:
    [...]
    Mainframes are the primary example I was thinking of. Btw, the
    latest incarnation of IBM's S/360/370/390 line is called
    "z/Architecture" and the z17 is the current top-of-the-line
    offering from Big Blue.

    Fwiw, do you remember reading A-45 from:

    https://www.ibm.com/docs/en/module_1678991624569/pdf/SA22-7832-14.pdf

    I read that sucker many times back in the day. PLO was pretty fun.

    That's "z/Architecture Principles of Operation", a 2240-page PDF.
    Page A-45 is "Multiprogramming and Multiprocessing Examples".

    Next time you post a link like that, tell us what it is so somebody
    else doesn't have to do it for you.


    Ok, shit. I have read that damn thing many times way back in the day. I
    just assumed without providing context. Scott and/or Dan most likely
    already have read it more than I have. :^)

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu May 28 07:33:51 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    Lawrence D?Oliveiro pisze:
    On Wed, 27 May 2026 15:33:46 +0200, fir wrote:

    ... imo nested scopes in functions practicaly imo have rather no to
    much big sense (imo for example fact that afair if and for loop have
    its on scope is most probably an error/mistake..is and loops are so
    called lightweight control structures not searate material scopes

    What?s ?lightweight? about it is that the local variables (including particularly the loop variable, if any) can mostly reside in
    registers. This can mean no necessity for any special stack setup at
    all, to enter and exit those constructs.

    i mean if you look on function code body like in half assembly level
    (by half assembly i mean you know that those loops and branches are
    like ip (instruction pointer) jumps in function...so you may see
    either those control structures/trajectories either more light in regard
    to variables they use or othervise you may see they maybe heavy an allocating/dealocating ram you can see as light in regard to control
    structures (maybe)

    as for now i rather see control structures 'light'..

    other think is you need scopes to preven pollution in big areas where
    you could have hundreds of accesible symbols and yet what maybe worse
    macros and things...inside function you rarely produce hundreds of
    symbols to make that pollution


    im not saying that having option for scope in function is absolutelly
    bad (im not sure) but afair i met some cases in my life whan i was
    rather annoyed i dont see "local" ariable in loop or maybe even in if
    block (i dont remember)


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Lawrence D?Oliveiro@3:633/10 to All on Thu May 28 05:37:51 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On Thu, 28 May 2026 07:33:51 +0200, fir wrote:

    Lawrence D?Oliveiro pisze:

    On Wed, 27 May 2026 15:33:46 +0200, fir wrote:

    ... imo nested scopes in functions practicaly imo have rather no
    to much big sense (imo for example fact that afair if and for loop
    have its on scope is most probably an error/mistake..is and loops
    are so called lightweight control structures not searate material
    scopes

    What?s ?lightweight? about it is that the local variables
    (including particularly the loop variable, if any) can mostly
    reside in registers. This can mean no necessity for any special
    stack setup at all, to enter and exit those constructs.

    i mean if you look on function code body like in half assembly level
    (by half assembly i mean you know that those loops and branches are
    like ip (instruction pointer) jumps in function...so you may see
    either those control structures/trajectories either more light in
    regard to variables they use or othervise you may see they maybe
    heavy an allocating/dealocating ram you can see as light in regard
    to control structures (maybe)

    That would be an ecumenical matter.

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu May 28 17:35:58 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    Lawrence D?Oliveiro pisze:
    On Thu, 28 May 2026 07:33:51 +0200, fir wrote:

    Lawrence D?Oliveiro pisze:

    On Wed, 27 May 2026 15:33:46 +0200, fir wrote:

    ... imo nested scopes in functions practicaly imo have rather no
    to much big sense (imo for example fact that afair if and for loop
    have its on scope is most probably an error/mistake..is and loops
    are so called lightweight control structures not searate material
    scopes

    What?s ?lightweight? about it is that the local variables
    (including particularly the loop variable, if any) can mostly
    reside in registers. This can mean no necessity for any special
    stack setup at all, to enter and exit those constructs.

    i mean if you look on function code body like in half assembly level
    (by half assembly i mean you know that those loops and branches are
    like ip (instruction pointer) jumps in function...so you may see
    either those control structures/trajectories either more light in
    regard to variables they use or othervise you may see they maybe
    heavy an allocating/dealocating ram you can see as light in regard
    to control structures (maybe)

    That would be an ecumenical matter.


    i mean controll structures not necessary (or mostly not) generat its own
    scope imo... function makes its own scope but control structures im not
    sure but maybe usually just not - i think they make opportunity to syntaxically make separate scopes but probably not 'semantically'


    often this is annoying like

    for(int i=0; i<tab_max;i++)
    {
    int sum = 0; sum+=tab[i];

    //should be int sum+=tab[i]; but this probably not compiles
    }
    return sum;

    is imo better than

    int sum = 0;
    for(int i=0; i<tab_max;i++)
    {
    sum+=tab[i];

    }
    return sum;

    also if for would have its own scope it would be like

    this code

    for(int i=0; i<tab_max;i++)
    {
    int sum = 0; sum+=tab[i];

    }
    was destroinng and creating (or at least assigning to 0 this sum
    variable maybe each time

    if it is not so it means this loop is lightweight becouse it not touches

    "int sum =0;"

    its (this ariable) is like a ghost to it - so the loop is lightweight

    the confusion is also that for and ifs use {} same as function
    definitions and this is confusing and maybe even just bad

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Bart@3:633/10 to All on Thu May 28 16:49:30 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 28/05/2026 16:35, fir wrote:
    Lawrence D?Oliveiro pisze:
    On Thu, 28 May 2026 07:33:51 +0200, fir wrote:

    Lawrence D?Oliveiro pisze:

    On Wed, 27 May 2026 15:33:46 +0200, fir wrote:

    ... imo nested scopes in functions practicaly imo have rather no
    to much big sense (imo for example fact that afair if and for loop
    have its on scope is most probably an error/mistake..is and loops
    are so called lightweight control structures not searate material
    scopes

    What?s ?lightweight? about it is that the local variables
    (including particularly the loop variable, if any) can mostly
    reside in registers. This can mean no necessity for any special
    stack setup at all, to enter and exit those constructs.

    i mean if you look on function code body like in half assembly level
    (by half assembly i mean you know that those loops and branches are
    like ip (instruction pointer) jumps in function...so you may see
    either those control structures/trajectories either more light in
    regard to variables they use or othervise you may see they maybe
    heavy an allocating/dealocating ram you can see as light in regard
    to control structures (maybe)

    That would be an ecumenical matter.


    i mean controll structures not necessary (or mostly not) generat its own scope imo... function makes its own scope but control structures im not
    sure but maybe usually just not - i think they make opportunity to syntaxically make separate scopes but probably not 'semantically'


    often this is annoying like

    for(int i=0; i<tab_max;i++)
    {
    ˙˙ int sum = 0; sum+=tab[i];

    ˙˙ //should be int sum+=tab[i]; but this probably not compiles
    }

    Try:

    for (int i=0, sum=0; i<tab_max; ++i) { sum += tab[i];}



    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From fir@3:633/10 to All on Thu May 28 18:04:07 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    Bart pisze:
    On 28/05/2026 16:35, fir wrote:
    Lawrence D?Oliveiro pisze:
    On Thu, 28 May 2026 07:33:51 +0200, fir wrote:

    Lawrence D?Oliveiro pisze:

    On Wed, 27 May 2026 15:33:46 +0200, fir wrote:

    ... imo nested scopes in functions practicaly imo have rather no
    to much big sense (imo for example fact that afair if and for loop >>>>>> have its on scope is most probably an error/mistake..is and loops
    are so called lightweight control structures not searate material
    scopes

    What?s ?lightweight? about it is that the local variables
    (including particularly the loop variable, if any) can mostly
    reside in registers. This can mean no necessity for any special
    stack setup at all, to enter and exit those constructs.

    i mean if you look on function code body like in half assembly level
    (by half assembly i mean you know that those loops and branches are
    like ip (instruction pointer) jumps in function...so you may see
    either those control structures/trajectories either more light in
    regard to variables they use or othervise you may see they maybe
    heavy an allocating/dealocating ram you can see as light in regard
    to control structures (maybe)

    That would be an ecumenical matter.


    i mean controll structures not necessary (or mostly not) generat its
    own scope imo... function makes its own scope but control structures
    im not sure but maybe usually just not - i think they make opportunity
    to syntaxically make separate scopes but probably not 'semantically'


    often this is annoying like

    for(int i=0; i<tab_max;i++)
    {
    ˙˙˙ int sum = 0; sum+=tab[i];

    ˙˙˙ //should be int sum+=tab[i]; but this probably not compiles
    }

    Try:

    ˙ for (int i=0, sum=0; i<tab_max; ++i) { sum += tab[i];}



    lol chat gpt said that for(;;) {int i=0; i++;}

    assigns this 0 each time so i never reach 2

    i didnt remembered that - i had often some problems to even remember not
    much logical things

    so it seems in c control structures are NOT lightweight where in reality
    they are probably lightweight by nature

    imo initialisation even of local variables should not be called
    (probably) many times

    i add "probably" becouse there is sligth chance i mislooked something
    but usually i probably not

    initialisation should go once so even such things

    for(;;) int x++;

    should work imo.. it seem to look weird but imo is rather ok


    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Mike Terry@3:633/10 to All on Fri May 29 04:01:38 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    On 28/05/2026 01:35, Waldek Hebisch wrote:
    Dan Cross <cross@spitfire.i.gajendra.net> wrote:
    In article <10v5pn8$2guem$1@dont-email.me>,
    Lynn McGuire <lynnmcguire5@gmail.com> wrote:
    On 5/26/2026 7:23 PM, Dan Cross wrote:
    In article <10v560l$2csvm$1@dont-email.me>,
    Lynn McGuire <lynnmcguire5@gmail.com> wrote:
    On 5/25/2026 8:46 AM, Kenny McCormack wrote:
    Trigger Warning: This post contains the dreaded "s word". Viewer
    discretion advised.
    [snip]

    What is the dreaded s word, scripting ?

    I think it's "stack". The C standard doesn't make any reference
    to call stacks or stack allocation, AFAIK. However, in practice
    most systems use one; there are a handful of exceptions however.

    I used to write assembly language on IBM 370s and Fortran on IBM 3090s.
    No stack that I know of. My prof in my IBM 370 assembly language class
    taught us how to create a simulated stack.

    I have no idea about modern IBM mainframes. I don't even know what
    their model number is.

    Mainframes are the primary example I was thinking of. Btw, the
    latest incarnation of IBM's S/360/370/390 line is called
    "z/Architecture" and the z17 is the current top-of-the-line
    offering from Big Blue.

    On older version of that ISA, function (nee procedure,
    subroutine, etc) calls are made by instructions that take a GP
    register operand that holds the address of the next instruction;
    that "link register" thus holds the function return address, and
    there is a "store multiple" instruction to write one or more
    registers to memory (excuse me, "storage" in IBM parlance); one
    presumes that a program (or a langauge; I'm assuming assembler
    here) adopts some convention for a designated link register, and
    writes it into a software-managed "save area" of memory on entry
    or before itself making a call. This is almost RISC-like, and
    unlike (say) x86 that automatically pushes the return address
    onto a hardware stack that is pointed to by a dedicated "stack
    pointer" register.

    At hardware level it is very similar to what ARM is doing, so
    yes, RISC uses essentially the same method. Difference is in
    management of "save area".

    I believe traditionally, entry into a function (nee procedure,
    subroutine, etc) involved allocating the temporary working space
    required for that subroutine, and adding that to a linked list
    of such allocations, as opposed to operating on a window into a
    single, larger region.

    Yes, that was general pattern. Irony of this was that general
    function call needed something like 2 machine level function
    calls.

    Performance critical non-reentant functions freqently had dedicated
    "save area".

    For the code I worked on (assembler, sysprog written, late 1980's) this was almost universal.
    Hardly any functions needed to be reentrant, and so routines typically had both their local data and
    save area incorporated into the routine itself. This saved an OS SVC (Getmain) to obtain separate
    storage per invocation. I don't think that was just local practice...

    Mike.


    But I see no reason a program couldn't
    allocate a large region and use another register as a "stack"
    pointer into that region in a more conventional way.

    AFAIK this is how IBM is doing this now, using pretty conventional
    stack.

    If one
    were feeling bold, one could even take a third register to use
    as a frame pointer. Idly, I wonder if one should refer to the
    more common kind of stack use as the more "conventional" way,
    since this mechanism in the lizard brain of z/arch predates most
    architectures in use today by a couple of decades.

    That aside, poking around briefly it looks like IBM supports
    "language environments" that seem roughly like runtimes and ABIs
    for, well, specific languages. One presumes different languages
    might do things in ways similar to other machines. I don't have
    time right now to look in more detail, but I see some indicators
    that this may be the case, and a few documents describing
    hardware mention stacks, so perhaps they've added some support
    in the 64-bit ISA.

    - Dan C.



    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Tim Rentsch@3:633/10 to All on Sun May 31 16:24:17 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    scott@slp53.sl.home (Scott Lurndal) writes:

    [asking about when the storage for local variables in
    nested blocks will be deallocated]

    Experimenting with gcc (4.8.3, 14.2.1) shows that the
    stack layout depends on -O.

    Sure. Isn't that what anyone would expect? (Not meant
    rhetorically.)

    int fff(int yyy, int xxx)
    {
    int ab = yyy + xxx;

    {
    int bb;
    printf("%p\n", &bb);
    }

    {
    int bc;
    printf("%p\n", &bc);
    }

    printf("%p\n", &ab);

    return 0;
    }

    This function has undefined behavior.

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)
  • From Keith Thompson@3:633/10 to All on Sun May 31 16:36:21 2026
    Subject: Re: Using gotos with local variables in "extra" blocks: Does it get deallocated?

    Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
    scott@slp53.sl.home (Scott Lurndal) writes:
    [...]
    int fff(int yyy, int xxx)
    {
    int ab = yyy + xxx;

    {
    int bb;
    printf("%p\n", &bb);
    }

    {
    int bc;
    printf("%p\n", &bc);
    }

    printf("%p\n", &ab);

    return 0;
    }

    This function has undefined behavior.

    Yes, it has undefined behavior because "%p" requires an argument
    of type void*. The second argument in each printf call should be
    cast to void*.

    Is that what you're referring to? Do you see any other instance
    of undefined behavior (assuming xxx + yyy doesn't overflow)?

    --
    Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
    void Void(void) { Void(); } /* The recursive call of the void */

    --- PyGate Linux v1.5.15
    * Origin: Dragon's Lair, PyGate NNTP<>Fido Gate (3:633/10)