Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #70977

Re: why "int s = setjmp(env)" fails?

Path csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: why "int s = setjmp(env)" fails?
Date Sun, 20 Sep 2015 11:11:02 -0400
Organization Self
Lines 29
Message-ID <55FECC86.9@verizon.net> (permalink)
References <d8e6c449-3aad-405e-b8a2-5fa73ee6a9a3@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding 7bit
Injection-Info mx02.eternal-september.org; posting-host="39e08c8e41e420e151f672c73609c593"; logging-data="10581"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18wWqnJ37YY2d9QOzOk0uq2oXlGvmJcP4s="
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0
In-Reply-To <d8e6c449-3aad-405e-b8a2-5fa73ee6a9a3@googlegroups.com>
Cancel-Lock sha1:h4zsDx78OsHPP4EjeZWEfW0iVX0=
Xref csiph.com comp.lang.c:70977

Show key headers only | View raw


On 09/20/2015 12:59 AM, i@introo.me wrote:
> while(setjmp(env)) will succeed,  (1)
> 
> however,
> 
> volatile int s = setjmp(env) will fail.  (2)
> 
> 
> what's the technical complexity/difficulty that hinders (2) ?
> 
> AFAIK, (2) is still a simple statment.

"Nobody" has already cited for you the relevant rules, and Eric Sosman
have given you the general context of why those rules were written that
way. But neither has explained specifically what the problem is. If you
look at the rules "Nobody" cited, you notice a common thread: every
place where setjmp() calls don't have undefined behavior falls into one
of two categories: the return value from setjmp is either completely
ignored, or is used immediately to determine how the code will branch,
without being stored anywhere, not even as a temporary in a more
complicated expression. It would appear to be the case that it's the
storage of the return value that the committee considered to be
problematic. Why? I don't know, I'm not an implementor, and the reason
isn't obvious to me - but that does seem to be the relevant issue.

If you want to know which value setjmp() returned, make it the
controlling expression of a switch() statement, and provide case:
statements for each value you're interested in distinguishing from the
default: case.

Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

why "int s = setjmp(env)" fails? i@introo.me - 2015-09-19 21:59 -0700
  Re: why "int s = setjmp(env)" fails? Nobody <nobody@nowhere.invalid> - 2015-09-20 10:53 +0100
  Re: why "int s = setjmp(env)" fails? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-09-20 07:47 -0400
    Re: why "int s = setjmp(env)" fails? supercat@casperkitty.com - 2015-09-21 08:51 -0700
      Re: why "int s = setjmp(env)" fails? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-09-21 12:52 -0400
        Re: why "int s = setjmp(env)" fails? supercat@casperkitty.com - 2015-09-21 11:44 -0700
          Re: why "int s = setjmp(env)" fails? Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-09-21 15:52 -0400
            Re: why "int s = setjmp(env)" fails? supercat@casperkitty.com - 2015-09-22 11:51 -0700
        Re: why "int s = setjmp(env)" fails? Tim Rentsch <txr@alumni.caltech.edu> - 2015-09-26 17:06 -0700
        Re: why "int s = setjmp(env)" fails? Paul N <gw7rib@aol.com> - 2015-09-28 14:28 -0700
  Re: why "int s = setjmp(env)" fails? Keith Thompson <kst-u@mib.org> - 2015-09-20 07:33 -0700
  Re: why "int s = setjmp(env)" fails? James Kuyper <jameskuyper@verizon.net> - 2015-09-20 11:11 -0400

csiph-web