Re: Question about setjmp on Itanium HPUX.

From: Keith Thompson (kst-u_at_mib.org)
Date: 11/19/04


Date: Fri, 19 Nov 2004 08:38:34 GMT

dhandly@convex.hp.com (Dennis Handly) writes:
> Keith Thompson (kst-u@mib.org) wrote:
> : Then the implementation needs to define jmp_buf so that any declared
> : object of that type will be aligned properly, even if it's a member of
> : a struct. It's free to use compiler magic if necessary (such as an
> : alignment #pragma).
>
> Unfortunately there is no such magic. pack overrides. :-(

I'm not sure what you mean by "pack", but I'm guessing you're
referring to an implementation-defined #pragma that causes struct
members to be packed more tightly than they normally would be. For
example, given something like

    struct foo { char c; double d; };
    #pragma pack struct foo /* or whatever the syntax is */
    struct foo obj;

I would expect the compiler to do whatever it needs to to make obj.d
accessible as a double. If obj.d is byte-aligned because of the
pragma, but the hardware requires stricter alignment, the compiler
probably needs to do something like the equivalent of a memcpy() to a
properly aligned chunk of memory to access the value. Perhaps it
handles this except in the special case of type jmp_buf, which
apparently requires 16-byte alignment.

But as it turns out this doesn't necessarily mean the compiler is
broken. C99 6.10.6p1 says:

    A preprocessing directive of the form

        # pragma pp-tokensopt new-line

    where the preprocessing token STDC does not immediately follow
    pragma in the directive (prior to any macro replacement) causes
    the implementation to behave in an implementation-defined
    manner. The behavior might cause translation to fail or cause the
    translator or the resulting program to behave in a non-conforming
    manner. Any such pragma that is not recognized by the
    implementation is ignored.

If that's not what you meant by "pack", please clarify.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
We must do something.  This is something.  Therefore, we must do this.


Relevant Pages

  • Re: Do not trust ALIGN
    ... #pragma pack ... Although I consider it a BUG in the compiler if those UNALIGNED atributes ... alignment of each member to it's native size. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Record representation : components order
    ... Convention to the type of the member of a record (not exactly ... A pragma Convention is used to specify that an Ada entity should use ... another language, but with another compiler. ...
    (comp.lang.ada)
  • Re: include file question
    ... Where did you read that #pragma once is obsolete? ... because it suggests that what you need is some kind of weird compiler hack to make your ... inside the header file to prevent multiple execution of the contents. ... documentation about Objective C, which is a language which is NOT the C++ language, has ...
    (microsoft.public.vc.mfc)
  • Re: Size of a structure : Structure Padding
    ... int i1; // 4 ... According to the rules of structure padding shouldn't the size of the ... it shouldn't be 28 bytes for a 32-bit compiler. ... It may very well be that the second member of your structure, ...
    (comp.lang.c)
  • Re: Passing a form reference gives error
    ... You mentioned "implement a common interface"... ... lstFormControls is not a member of "System.Windows.Forms.Form" ... member called lstFormControls. ... compiler and shouldn't matter at runtime. ...
    (microsoft.public.dotnet.languages.vb)