This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: cleanup handlers and longjmp


> Hmm, I'd expect words like "unspecified" or "implementation defined"
> to be used for the case you describe, and "undefined (behaviuor)" for
> foridden stuff.

From ISO C 99:

       3.4.3
       [#1] undefined behavior
       behavior,  upon  use  of  a nonportable or erroneous program
       construct or of erroneous data, for which this International
       Standard imposes no requirements

       [#2]  NOTE  Possible undefined behavior ranges from ignoring
       the situation  completely  with  unpredictable  results,  to
       behaving  during  translation  or  program  execution  in  a
       documented manner characteristic of the environment (with or
       without   the   issuance   of   a  diagnostic  message),  to
       terminating a translation or execution (with the issuance of
       a diagnostic message).

So 'behaving ... in a documented manner' is certainly one possibility
that the authors of C had in mind. Furthermore,

       4. [#6] A conforming implementation may have extensions
       (including additional library functions), provided they do not
       alter the behavior of any strictly conforming program.3)

So an extension is a feature that does not effect the behaviour of a
strictly conforming program

       [#5] A strictly conforming  program  shall  use  only  those
       features  of  the  language  and  library  specified in this
       International  Standard.2)   It  shall  not  produce  output
       dependent on any unspecified, undefined, or  implementation-
       defined   behavior,   and   shall  not  exceed  any  minimum
       implementation limit.

Since using cleanup handlers and setjmp together invokes undefined
behaviour, a program doing so is not strictly conforming. Therefore,
extensions may provide a definition for the behaviour where the
standard does not (as is the case with every extension).

Regards,
Martin

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]