Mail Archives: pgcc/2000/01/10/20:26:07
hello,
if this helps i get the same result with gcc on my Ultrasparc. i
also get an extra print... when the result is wrong..
Shoe Lace.
------
$ gcc -v
Reading specs from
/opt/local/packages/gcc-2.95.2/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/specs
gcc version 2.95.2 19991024 (release)
$ gcc t.cpp -o t
$ ./t
2 p=EFFFF2CE, p=EFFFF2CE
2 p=EFFFF2E8, p=EFFFF2E8
2 p=EFFFF2EA, p=EFFFF2EA
2 p=EFFFF2FF, p=EFFFF2FF
2 p=EFFFF2E8, p=EFFFF2E8
$ gcc t.cpp -o t -O1
$ ./t
2 p=EFFFF2DE, p=EFFFF2DE
2 p=EFFFF2F8, p=EFFFF2F8
2 p=EFFFF2FA, p=EFFFF2FA
2 p=EFFFF30F, p=EFFFF30F
2 p=EFFFF2F8, p=EFFFF2CC
2 p=EFFFF2CE, p=F000282E
At 16:10 10/01/00 +0100, Juan Altmayer Pizzorno wrote:
>Hi,
>
>the attached file was "factored out" of a program that, among other
>things, does DNS queries. The code between the printf()'s seems to
>affect the value of variable 'p', even though it shouldn't... When
>compiled with -O0 or no -O flags, it runs correctly. But when compiled
>with -O1 and above, it does not. I've tried it with several different
>versions of the compiler (egcs 2.91.66 from plain RedHat, egcs 2.95.2
>from the official release, and pgcc 2.95.3 with the pgcc-2_95_3 tag
>out of your CVS), all with identical results. BTW pgcc-2_95_3 still
>identifies itself as 2.95.2... The second attachment is "t.E", obtained
>with g++ -E t.cxx > t.E. This is all on a Pentium II, RedHat 6.1,
>kernel 2.2.14-based notebook. Thanks
>
>.. Juan
>
>$ g++ --version
>pgcc-2.95.2
>$ g++ -O1 -o t t.cxx
>$ ./t
>2 p=BFFFFA92, p=BFFFFA92
>2 p=BFFFFAAC, p=BFFFFAAC
>2 p=BFFFFAAE, p=BFFFFAAE
>2 p=BFFFFAC3, p=BFFFFAC3
>2 p=BFFFFAAC, p=BFFFFA80 <--- should have been identical
>2 p=BFFFFA82, p=C0002FE2 <--- should have been identical// $Id: t.cxx,v
>1.12 2000/01/10 13:31:34 juan Exp $
>
>/*
>$ g++ --version
>pgcc-2.95.2
>$ g++ -O1 -o t t.cxx
>$ ./t
>2 p=BFFFFA92, p=BFFFFA92
>2 p=BFFFFAAC, p=BFFFFAAC
>2 p=BFFFFAAE, p=BFFFFAAE
>2 p=BFFFFAC3, p=BFFFFAC3
>2 p=BFFFFAAC, p=BFFFFA80 <---
>2 p=BFFFFA82, p=C0002FE2 <---
>*/
>
>#include <stdio.h>
>typedef unsigned char uchar;
>
>static int
>ExtractName (uchar* header, uchar*& p, uchar* end)
>{
>//printf ("1 p=%X\n", p);
> if (p >= end)
> return 1;
>
> register unsigned length;
>
> while ((length = *p++))
> {
> if (length & 0xc0)
> {
> uchar* jump;
>
> // compute offset in 'length', new 'p' in 'jump'
> length = ((length & 0x3F) << 8) | *p;
>
>printf ("2 p=%X, ", p);
>
> jump = header + length;
>
>printf ("p=%X\n", p);
>
> // advance 'p' to final position
> ++p;
>
> return ExtractName (header, jump, end);
> }
> else
> {
> if (p + length > end)
> return 1;
>
> p += length;
> }
> }
>
>//printf ("3 p=%X\n", p);
> if (p > end)
> return 1;
>
> return 0;
>}
>
>int
>main (int argc, char* argv[])
>{
> uchar buffer[] = {
>
>0x00,0x01,0x81,0x80,0x00,0x01,0x00,0x02,0x00,0x04,0x00,0x06,0x08,0x75,0x6E,
>0x69,
>
>0x2D,0x62,0x6F,0x6E,0x6E,0x02,0x64,0x65,0x00,0x00,0x0F,0x00,0x01,0xC0,0x0C,
>0x00,
>
>0x0F,0x00,0x01,0x00,0x00,0x03,0x84,0x00,0x10,0x00,0x0A,0x06,0x6E,0x6F,0x64,
>0x65,
>
>0x30,0x33,0x04,0x72,0x68,0x72,0x7A,0xC0,0x0C,0xC0,0x0C,0x00,0x0F,0x00,0x01,
>0x00,
>
>0x00,0x03,0x84,0x00,0x0B,0x00,0x14,0x06,0x6E,0x6F,0x64,0x65,0x30,0x35,0xC0,
>0x32,
>
>0xC0,0x0C,0x00,0x02,0x00,0x01,0x00,0x01,0x51,0x80,0x00,0x06,0x03,0x4E,0x49,
>0x43,
>
>0xC0,0x32,0xC0,0x0C,0x00,0x02,0x00,0x01,0x00,0x01,0x51,0x80,0x00,0x0D,0x0A,
>0x6E,
>
>0x6F,0x64,0x65,0x30,0x33,0x2D,0x65,0x6E,0x32,0xC0,0x32,0xC0,0x0C,0x00,0x02,
>0x00,
>
>0x01,0x00,0x01,0x51,0x80,0x00,0x09,0x06,0x6E,0x6F,0x64,0x65,0x30,0x38,0xC0,
>0x32,
>
>0xC0,0x0C,0x00,0x02,0x00,0x01,0x00,0x01,0x51,0x80,0x00,0x17,0x07,0x77,0x73,
>0x2D,
>
>0x6D,0x75,0x65,0x31,0x06,0x77,0x69,0x6E,0x2D,0x69,0x70,0x03,0x64,0x66,0x6E,
>0x02,
>
>0x64,0x65,0x00,0xC0,0x2B,0x00,0x01,0x00,0x01,0x00,0x01,0x51,0x80,0x00,0x04,
>0x83,
>
>0xDC,0x12,0x85,0xC0,0x47,0x00,0x01,0x00,0x01,0x00,0x01,0x51,0x80,0x00,0x04,
>0x83,
>
>0xDC,0x12,0x87,0xC0,0x5C,0x00,0x01,0x00,0x01,0x00,0x01,0x51,0x80,0x00,0x04,
>0x83,
>
>0xDC,0x10,0xDC,0xC0,0x6E,0x00,0x01,0x00,0x01,0x00,0x01,0x51,0x80,0x00,0x04,
>0x83,
>
>0xDC,0x0E,0xCB,0xC0,0x87,0x00,0x01,0x00,0x01,0x00,0x01,0x51,0x80,0x00,0x04,
>0x83,
>
>0xDC,0x12,0x8A,0xC0,0x9C,0x00,0x01,0x00,0x01,0x00,0x00,0xF2,0x41,0x00,0x04,
>0xC1,
> 0xAE,0x4B,0xA6
> };
>
> int rc;
> unsigned i;
> uchar* p = buffer;
> uchar* end = buffer + sizeof (buffer);
>
> // position at 1st answer
> p = buffer + 0x1D;
>
> // get owner
> if ((rc = ExtractName (buffer, p, end)))
> exit (1);
>
> // skip type(2), class(2), ttl(4), rdlength(2), MX preference(2)
> p += 2 + 2 + 4 + 2 + 2;
>
> // get mailer name
> if ((rc = ExtractName (buffer, p, end)))
> exit (1);
>
> // get owner
> if ((rc = ExtractName (buffer, p, end)))
> exit (1);
>
> // skip type(2), class(2), ttl(4), rdlength(2), MX preference(2)
> p += 2 + 2 + 4 + 2 + 2;
>
> // get mailer name
> if ((rc = ExtractName (buffer, p, end)))
> exit (1);
>
> return 0;
>}
<-- rest snipped-->
Shoe Lace. (a.k.a David)
--
Important Notice: The contents of this email transmission, including
attachments, may be privileged and confidential. Any unauthorised use of
the contents is expressly prohibited. If you have received this
transmission in error, please advise the sender by return email or
telephone immediately and destroy all versions.
- Raw text -