Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Re: axp/gcc the double cast gets trashed on return
@ 1997-10-06 18:35 Uncle George
  0 siblings, 0 replies; 4+ messages in thread
From: Uncle George @ 1997-10-06 18:35 UTC (permalink / raw)


Richard Henderson wrote:

> On Mon, Oct 06, 1997 at 10:49:36AM -0400, Uncle George wrote:
> >
> If you compile this with optimization, the compiler will elide the
> store to d.dd since (1) it is a local variable, thus there are no
> side effects once the function is complete and (2) the value is not
> used.
>
> Make d global or static and you'll see it gets the right value.

done that, no avail. This excerpt was taken from another pgm ( the java jvm )
when the double test failed.
looked at the assembler, but dont see the prob. maybe u like to try it - maybe u
can tellme how to look at float regs
in gdb.
gat

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 4+ messages in thread
[parent not found: <3438FA7E.E8FD1D28@voicenet.com>]
* axp/gcc the double cast gets trashed on return
@ 1997-10-06 14:49 Uncle George
  0 siblings, 0 replies; 4+ messages in thread
From: Uncle George @ 1997-10-06 14:49 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2531 bytes --]

--------------719205A674A3765CD026A878
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,tell me why the double value returned from go_convert() is not 7.0???
If u step through ( via gdb ) the val l.dd = 7, x.dd = 7,

    BUT d.dd is some bogus number. d.dd should have 7.0

Am I doing something wrong ( u cannot change the code, unless there is a "C"
violation somewhere!!!!)

GAT

PS, thanks for the SIGNAL/FPE syscall. u should note ( although I havent verified )

that a sigfpe is still possible on a double conversion to long.

*********************************************************
typedef long    int64_t;
double go_convert ( int64_t );
main()
{
        union {
                long    ll;
                double  dd;
        } l, d;
        l.ll = 0x401c000000000000;
        d.dd = go_convert ( l.ll );
}
double
go_convert( int64_t v )
{
union   {
        long ll;
        double dd ;
} x;
        x.ll = v;
        return(x.dd);
}

> --
> To unsubscribe: send e-mail to axp-list-request@redhat.com with
> 'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

--------------719205A674A3765CD026A878
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,tell me why the double value returned from go_convert() is not 7.0???

If u step through ( via gdb ) the val l.dd = 7, x.dd = 7,

    BUT d.dd is some bogus number. d.dd
should have 7.0

Am I doing something wrong ( u cannot change the code, unless there
is a "C"

violation somewhere!!!!)

GAT

PS, thanks for the SIGNAL/FPE syscall. u should note ( although I havent
verified )

that a sigfpe is still possible on a double conversion to long.

*********************************************************

typedef long    int64_t;

double go_convert ( int64_t );

main()

{

        union {

               
long    ll;

               
double  dd;

        } l, d;

        l.ll = 0x401c000000000000;

        d.dd = go_convert ( l.ll
);

}

double

go_convert( int64_t v )

{

union   {

        long ll;

        double dd ;

} x;

        x.ll = v;

        return(x.dd);

}
--

To unsubscribe: send e-mail to axp-list-request@redhat.com with

'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com
 

--------------719205A674A3765CD026A878--

--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1997-10-07  0:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-10-06 18:35 axp/gcc the double cast gets trashed on return Uncle George
     [not found] <3438FA7E.E8FD1D28@voicenet.com>
1997-10-06 17:03 ` Richard Henderson
1997-10-07  0:08 ` Volker Barthelmann
  -- strict thread matches above, loose matches on Subject: below --
1997-10-06 14:49 Uncle George

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox