This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Adding UNION/MAP -- Feedback and tips pls!
- From: Thomas Koenig <tkoenig at netcologne dot de>
- To: gcc at gcc dot gnu dot org
- Cc: "fortran at gcc dot gnu dot org" <fortran at gcc dot gnu dot org>
- Date: Wed, 06 Mar 2013 19:35:25 +0100
- Subject: Re: Adding UNION/MAP -- Feedback and tips pls!
- References: <51314549.6080902@earthlink.net> <Prayer.1.3.5.1303020815470.18790@hermes-1.csi.cam.ac.uk> <CAGkQGiL7Qg0RAqJrT5i4LDzjnsr3jQ42Ws2BQFDpPUHyQe3+WQ@mail.gmail.com> <CAKwh3qgyS0nRcGSE5UT+DN+11kjYRE9Vu7SsQ_AGPtuD7VV4dA@mail.gmail.com> <Prayer.1.3.5.1303021519480.2329@hermes-1.csi.cam.ac.uk> <CAAKgPaHZwaoSBVg-hNZxan-uAtnmEBjPxyv9iuh=xdOshFp1uQ@mail.gmail.com> <Prayer.1.3.5.1303041813340.19357@hermes-1.csi.cam.ac.uk> <CAAKgPaGtNQoA=2h+5Z8DmvgsEBKUKX78Ojwi_SY2RG8hUcksOg@mail.gmail.com> <Prayer.1.3.5.1303042034040.18634@hermes-1.csi.cam.ac.uk>
Am 04.03.2013 21:34, schrieb N.M. Maclaren:
(quoting documentation about DEC UNIONs for Fortran)
"However, if you overlay one variable with another smaller variable,
that portion of the initial variable is retained that is not overlaid.
Depending on the application, the retained portion of an overlaid variable
may or may not contain meaningful data and can be utilized at a later
point in the program."
Ouch.
This seems to be at odds with C's unions, where it is not allowed to do
type punning.
This probably means that it would be necessary to present a DEC Fortran
union to the middle end as something like
union {
char buff[8];
double b;
int c;
}
and then only do assignment with memcpy() to buff.
I think you're right - if we add this to gfortran, it should live behind
-fdo-you-really-want-to-use-dec-unions-yes-well-in-that-case-i-ll-let-you
or an options with a similar name.
Thomas