Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Shao Miller <sha0.miller@gmail.com> |
|---|---|
| Newsgroups | comp.std.c |
| Subject | Unsequenced Side Effects on the Same Union |
| Date | 2013-01-15 22:32 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <kd570b$mvc$1@dont-email.me> (permalink) |
#include <stdio.h>
void func1(void * vp1, void * vp2) {
int * ip;
double * dp;
/* Populate ip and dp? */
if (!vp1 && !vp2) {
func1(&ip, &dp);
/*
* 6.5p2: Unsequenced side effects
* on the same... Scalar?
*/
printf("%f\n", (*ip = 42) + (*dp = 3.14));
}
/* Self-called? */
if (vp1 && vp2) {
/* Aliasing shoved down here */
static union {
int i;
double d;
} u;
*(int **) vp1 = &u.i;
*(double **) vp2 = &u.d;
}
}
int main(void) { func1(NULL, NULL); return 0; }
Sorry all, I'm puzzled... This surely yields undefined behaviour, but
why, in C11? 6.5p2 changed from that of C99. Is it because one of the
'+' operands could establish an effective type before the other?
Hopefully they are not simultaneous.
--
- Shao Miller
--
"Thank you for the kind words; those are the kind of words I like to hear.
Cheerily," -- Richard Harter
Back to comp.std.c | Previous | Next — Next in thread | Find similar | Unroll thread
Unsequenced Side Effects on the Same Union Shao Miller <sha0.miller@gmail.com> - 2013-01-15 22:32 -0500
Re: Unsequenced Side Effects on the Same Union Nick Bowler <nbowler@draconx.ca> - 2013-01-16 14:55 +0000
Re: Unsequenced Side Effects on the Same Union Shao Miller <sha0.miller@gmail.com> - 2013-01-16 10:53 -0500
Re: Unsequenced Side Effects on the Same Union James Kuyper <jameskuyper@verizon.net> - 2013-01-16 11:04 -0500
Re: Unsequenced Side Effects on the Same Union Nick Bowler <nbowler@draconx.ca> - 2013-01-16 20:56 +0000
Re: Unsequenced Side Effects on the Same Union Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-17 13:21 -0800
Re: Unsequenced Side Effects on the Same Union Shao Miller <sha0.miller@gmail.com> - 2013-01-17 17:50 -0500
Re: Unsequenced Side Effects on the Same Union Tim Rentsch <txr@alumni.caltech.edu> - 2013-01-18 11:25 -0800
Re: Unsequenced Side Effects on the Same Union Shao Miller <sha0.miller@gmail.com> - 2013-01-18 15:07 -0500
csiph-web