guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

aliasing (was: guile loses on NetBSD/sparc64 1.6.2 with gcc 3.3.2)


From: Paul Jarc
Subject: aliasing (was: guile loses on NetBSD/sparc64 1.6.2 with gcc 3.3.2)
Date: Fri, 27 Feb 2004 13:38:41 -0500
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux)

Rob Browning <address@hidden> wrote:
> Also, I think you may be able to use a union safely as an
> alternative with gcc, but from what I recall, that's non-standard.

I don't think it's generally possible for gcc to handle that case
specially.  Consider:

void foo(int* i, float* f) { *i=42; *f=3.14159; }

void bar(void) {
  union { int i; float f; } u;
  foo(&u.i, &u.f);
  /* What's in u.f now? */
}

These functions could appear in different source files.  So when foo
is being compiled, the compiler can't know whether i and f point to
overlapping members of the same union.  It assumes they don't overlap
because of their types, and reorders the writes if it likes.


paul




reply via email to

[Prev in Thread] Current Thread [Next in Thread]