* OSF/1 3.0 C -O0 bug
@ 1994-10-08 16:46 Mark Charette
1994-10-08 17:06 ` Mark Charette
1994-10-10 14:43 ` Ken Cowan
0 siblings, 2 replies; 3+ messages in thread
From: Mark Charette @ 1994-10-08 16:46 UTC (permalink / raw)
While compiling some code for debugging purposes & setting the optimization
level to 0, I discovered the following anomaly, making -O0 useless for my
debugging:
#include <stdio.h>
int main(void)
{
double d;
double *dp;
unsigned int left = 2;
unsigned int order = 3;
dp = &d;
printf("%p\n",dp;
dp += left - order + 1;
printf("%p\n",dp);
return 0;
}
Under cc -migrate -O1 the program prints out:
11ffffaa8
11ffffaa8
Under cc -migrate -O0 the program prints out:
11ffffaa8
21ffffaa8
Not exactly what I expected under O0, even if subtracting unsigned ints
in that manner is not "good programming practice".
---------------------
Mark Charette
MIKA Systems
17197 N. Laurel Park Dr.
Suite 115
Livonia, MI 48152
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: OSF/1 3.0 C -O0 bug
1994-10-08 16:46 OSF/1 3.0 C -O0 bug Mark Charette
@ 1994-10-08 17:06 ` Mark Charette
1994-10-10 14:43 ` Ken Cowan
1 sibling, 0 replies; 3+ messages in thread
From: Mark Charette @ 1994-10-08 17:06 UTC (permalink / raw)
Mark Charette (charette@ultoe.det.dec.com) wrote:
: While compiling some code for debugging purposes & setting the optimization
: level to 0, I discovered the following anomaly, making -O0 useless for my
: debugging:
Following up to my own post (I should have known better):
This problem also manifests itself at higher optimization levels on non-
trivial codes.
I like the performance with -migrate, but I'm afraid to use it ;^(
--
Mark Charette "Don't crush that dwarf; hand me the pliers"
MIKA Systems, Inc. - Firesign Theater
17197 N. Laurel Park Dr Suite 115
Livonia, MI 48152 charette@mika.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: OSF/1 3.0 C -O0 bug
1994-10-08 16:46 OSF/1 3.0 C -O0 bug Mark Charette
1994-10-08 17:06 ` Mark Charette
@ 1994-10-10 14:43 ` Ken Cowan
1 sibling, 0 replies; 3+ messages in thread
From: Ken Cowan @ 1994-10-10 14:43 UTC (permalink / raw)
In article <376icb$s9e@eccdb1.pms.ford.com>, charette@ultoe.det.dec.com (Mark Charette) writes:
|>While compiling some code for debugging purposes & setting the optimization
|>level to 0, I discovered the following anomaly, making -O0 useless for my
|>debugging:
|>
|>#include <stdio.h>
|>
|>int main(void)
|>{
|>double d;
|>double *dp;
|>unsigned int left = 2;
|>unsigned int order = 3;
|>
|> dp = &d;
|>
|> printf("%p\n",dp;
|> dp += left - order + 1;
|> printf("%p\n",dp);
|>
|> return 0;
|>}
|>
|>Under cc -migrate -O1 the program prints out:
|>11ffffaa8
|>11ffffaa8
|>
|>Under cc -migrate -O0 the program prints out:
|>11ffffaa8
|>21ffffaa8
|>
|>Not exactly what I expected under O0, even if subtracting unsigned ints
|>in that manner is not "good programming practice".
|>
|>---------------------
|>Mark Charette
|>MIKA Systems
|>17197 N. Laurel Park Dr.
|>Suite 115
|>Livonia, MI 48152
|>
|>
|>
I recently saw a similar discussion elsewhere that boiled down
to "negative unsigned ints" being defined in the C standard
as implementation defined. What is the value of 2u - 3u?
This may be a real pain, but change your types to int if
they can be negative or change the expression to
(left + 1) - order which will have well defined behavior
in all compilers for left = 2u, order = 3u.
--
Ken Cowan, ZK2-3/Q8 cowan@rtl.enet.dec.com
Digital Equipment Corporation decwrl!rtl!cowan
110 Spit Brook Rd,
Nashua, NH 03062
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1994-10-10 14:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-10-08 16:46 OSF/1 3.0 C -O0 bug Mark Charette
1994-10-08 17:06 ` Mark Charette
1994-10-10 14:43 ` Ken Cowan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox