On 2007/03/19 19:12, Gustavo Rios wrote:
> I am writing a very simple program but the output change for the c
> variable value change every time i run it.
It doesn't do this on any system I've tried it on -
>i386, amd64:
x:8589934593
0,1:1,2
c:2
>sparc64:
x:8589934593
0,1:2,1
c:2
On Mon, 19 Mar 2007, Matthew R. Dempsky wrote:
> On Mon, Mar 19, 2007 at 09:55:04PM -0400, Paul D. Ouderkirk wrote:
> > And because I love to reply to myself, if I compile it with -O3, I can
> > reproduce your results:
>
> -O3 enables -fstrict-aliasing, which this program violates. The man
> pag
On Tue, 20 Mar 2007, Tobias Ulmer wrote:
> /*
> * You assume that the in memory representation of an
> * unsigned [2] looks exactly like unsigned long long and you
> * expect to access the valid initialized memory of x by
> * dereferencing p.
> *
> * These assumptions are all wrong.
>
On Mon, Mar 19, 2007 at 07:12:24PM -0300, Gustavo Rios wrote:
> I am writing a very simple program but the output change for the c
> variable value change every time i run it. What would it be my mistake
> on the source? Did i forget some thing?
>
> #include
>
> int
> main(int argc, char **argv)
On Mon, Mar 19, 2007 at 09:55:04PM -0400, Paul D. Ouderkirk wrote:
> And because I love to reply to myself, if I compile it with -O3, I can
> reproduce your results:
-O3 enables -fstrict-aliasing, which this program violates. The man
page explains in more detail.
On Tue, Mar 20, 2007 at 04:40:08AM +0200, [EMAIL PROTECTED] wrote:
> Compile it with -O3. Then enjoy.
Sure. Then I'll light my hair on fire and put it out with a ballpeen
hammer.
--
Darrin Chandler | Phoenix BSD Users Group
[EMAIL PROTECTED] | http://bsd.phoenix.az.u
"Gustavo Rios" <[EMAIL PROTECTED]> wrote:
> I am writing a very simple program but the output change for the c
> variable value change every time i run it. What would it be my mistake
> on the source? Did i forget some thing?
Bleh, what a depressing thread. Gustavo, why didn't you bother to
prov
On Mon, Mar 19, 2007 at 07:17:46PM -0700, Darrin Chandler wrote:
> On Mon, Mar 19, 2007 at 07:12:24PM -0300, Gustavo Rios wrote:
> > I am writing a very simple program but the output change for the c
> > variable value change every time i run it. What would it be my mistake
> > on the source? Did i
On Mon, Mar 19, 2007 at 07:12:24PM -0300, Gustavo Rios wrote:
> I am writing a very simple program but the output change for the c
> variable value change every time i run it. What would it be my mistake
> on the source? Did i forget some thing?
>
> #include
>
> int
> main(int argc, char **argv)
On Tue, Mar 20, 2007 at 01:35:28AM +0100, Frank Denis wrote:
> Le Mon, Mar 19, 2007 at 07:12:24PM -0300, Gustavo Rios ecrivait :
> >I am writing a very simple program but the output change for the c
> >variable value change every time i run it.
> >int
> >main(int argc, char **argv)
> >{
> > u
On Mon, Mar 19, 2007 at 08:02:10PM -0400, Nick ! wrote:
> Wait, how is * defined on two voids? That shouldn't even compile
> (unless it's autocasting to int?).
``unsigned'' is short for ``unsigned int''. The ``(void *)'' cast is
a red herring.
On 3/19/07, Paul D. Ouderkirk <[EMAIL PROTECTED]> wrote:
On 3/19/07, Gustavo Rios <[EMAIL PROTECTED]> wrote:
> No!
>
> p sizeof is 4 bytes, p is the frst byt of &x, and p + 1 is the 4th
> byte. Casting is only on attribution of &x to p.
>
> Realize, p[0] evals to 1 and p[1] evals to 2 as it shoul
On 3/19/07, Gustavo Rios <[EMAIL PROTECTED]> wrote:
No!
p sizeof is 4 bytes, p is the frst byt of &x, and p + 1 is the 4th
byte. Casting is only on attribution of &x to p.
Realize, p[0] evals to 1 and p[1] evals to 2 as it should be. Only
problem relates to p[0] * p[1]. I believe it should (1 *
Whenever a printf "fixes everything", it's usually because that forces
gcc to put the values on the stack. Without the printf, they're
probably in registers and p points to who knows what.
If you grok assembly, try objdump on the executable to see what's
going on. If you want to multiply the tw
No!
p sizeof is 4 bytes, p is the frst byt of &x, and p + 1 is the 4th
byte. Casting is only on attribution of &x to p.
Realize, p[0] evals to 1 and p[1] evals to 2 as it should be. Only
problem relates to p[0] * p[1]. I believe it should (1 * 2), i.e., 2.
Not a random value.
On 3/19/07, Nick !
Le Mon, Mar 19, 2007 at 07:12:24PM -0300, Gustavo Rios ecrivait :
I am writing a very simple program but the output change for the c
variable value change every time i run it.
int
main(int argc, char **argv)
{
unsigned long long x, c;
unsigned*p;
p = (voi
On 3/19/07, Gustavo Rios <[EMAIL PROTECTED]> wrote:
On 3/19/07, Nick ! <[EMAIL PROTECTED]> wrote:
> On 3/19/07, Gustavo Rios <[EMAIL PROTECTED]> wrote:
> > I am writing a very simple program but the output change for the c
> > variable value change every time i run it. What would it be my mistak
So, why when i printf p[1], it correctly prints 2?
On 3/19/07, Nick ! <[EMAIL PROTECTED]> wrote:
On 3/19/07, Gustavo Rios <[EMAIL PROTECTED]> wrote:
> I am writing a very simple program but the output change for the c
> variable value change every time i run it. What would it be my mistake
> on
On 3/19/07, Gustavo Rios <[EMAIL PROTECTED]> wrote:
I am writing a very simple program but the output change for the c
variable value change every time i run it. What would it be my mistake
on the source? Did i forget some thing?
#include
int
main(int argc, char **argv)
{
unsigned long
I am writing a very simple program but the output change for the c
variable value change every time i run it. What would it be my mistake
on the source? Did i forget some thing?
#include
int
main(int argc, char **argv)
{
unsigned long long x, c;
unsigned*p;
20 matches
Mail list logo