Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Floating point on alpha
@ 2002-07-02 12:10 Linus Gasser
  2002-07-02 12:33 ` Doug Trainor
  2002-07-02 13:01 ` Christian Iseli
  0 siblings, 2 replies; 8+ messages in thread
From: Linus Gasser @ 2002-07-02 12:10 UTC (permalink / raw)
  To: axp-list

Hi all,
I have a general question for alphas: from time to time when I try to compile 
a program for my alpha (PC164), I run into problems with doubles. For example

{
	double a;

	if ( a ){
		printf( "love\n" );
	} else {
		printf( "peace\n" );
	}
}

seems to run w/o problems on an i386 and produces "peace" as output. Now, on 
an alpha (can't test it right now, but try it out and tell me), it segfaults, 
cause 'a' is not defined. Seems logical to me. But as it runs on i386, lots 
of programs have this kind of logic (gnome-print had it, breakout2 had it, 
scribus had it, noteedit has it (note the had/has and try to figure out which 
program I'd like to run on my alpha ;-) ).
 Now my question: is it possible to remove this behaviour with a good 
compiler-switch? Because going over these programs, searching for 
non-initialised doubles gets on my nerves. OK, I should, as it is really bad 
programming, and I could contribute like this (and did sometimes). But 
still... Any hints?

Ineiti

PS: if this 'magic' compiler switch doesn't exist, I have a question about gdb 
with libraries and how to use the '-g' switch in this case. Just to find 
those #@$%-variables...




^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: Floating point on alpha
@ 2002-07-02 13:10 Peter Petrakis
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Petrakis @ 2002-07-02 13:10 UTC (permalink / raw)
  To: axp-list

Well,
Adding '-mieee' to your compile flags will solve the FPE however you
may be better off to cast the comparison to an (int). Testing for
the positive case doesn't require 64 bits of precision ;-P .

Peter



> ineiti@gmx.net said:
> > I have a general question for alphas: from time to time when I try to
> > compile  a program for my alpha (PC164), I run into problems with
> > doubles. For example
> 
> > {
> > 	double a;
> 
> > 	if ( a ){
> > 		printf( "love\n" );
> > 	} else {
> > 		printf( "peace\n" );
> > 	} }
> 
> Ah, well.  If your whole point is avoid a crash, you can always try:
> 
> #include <signal.h>
> static void myHandler(int i)
> {
>   signal(i, myHandler);
> }
> 
> And add this near the start of the main program:
> 
>   signal(SIGFPE, myHandler);
> 
> But then again, it might be better to actually fix the code...
> 
> Cheers,
> 					Christian
> 
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list



--
www.alphadriven.org




^ permalink raw reply	[flat|nested] 8+ messages in thread
* RE: Floating point on alpha
@ 2002-07-08 22:54 Donsbach, Jeff
  2002-07-09  2:42 ` Alvin Starr
  0 siblings, 1 reply; 8+ messages in thread
From: Donsbach, Jeff @ 2002-07-08 22:54 UTC (permalink / raw)
  To: axp-list

Purify would flag this usage of "a" as a "UMR" or uninitialized memory read. I.e. it is a lurking bug. Stack variables are not required to be initialized to zero as the code seems to assume.


> -----Original Message-----
> From: Linus Gasser [mailto:ineiti@gmx.net]
> Sent: Tuesday, July 02, 2002 8:11 AM
> To: axp-list@redhat.com
> Subject: Floating point on alpha
> 
> 
> Hi all,
> I have a general question for alphas: from time to time when 
> I try to compile 
> a program for my alpha (PC164), I run into problems with 
> doubles. For example
> 
> {
> 	double a;
> 
> 	if ( a ){
> 		printf( "love\n" );
> 	} else {
> 		printf( "peace\n" );
> 	}
> }
> 
> seems to run w/o problems on an i386 and produces "peace" as 
> output. Now, on 
> an alpha (can't test it right now, but try it out and tell 
> me), it segfaults, 
> cause 'a' is not defined. Seems logical to me. But as it runs 
> on i386, lots 
> of programs have this kind of logic (gnome-print had it, 
> breakout2 had it, 
> scribus had it, noteedit has it (note the had/has and try to 
> figure out which 
> program I'd like to run on my alpha ;-) ).
>  Now my question: is it possible to remove this behaviour with a good 
> compiler-switch? Because going over these programs, searching for 
> non-initialised doubles gets on my nerves. OK, I should, as 
> it is really bad 
> programming, and I could contribute like this (and did 
> sometimes). But 
> still... Any hints?
> 
> Ineiti
> 
> PS: if this 'magic' compiler switch doesn't exist, I have a 
> question about gdb 
> with libraries and how to use the '-g' switch in this case. 
> Just to find 
> those #@$%-variables...
> 
> 
> 
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list
> 




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

end of thread, other threads:[~2002-07-09  2:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-07-02 12:10 Floating point on alpha Linus Gasser
2002-07-02 12:33 ` Doug Trainor
2002-07-02 14:03   ` Linus Gasser
2002-07-02 14:22     ` Joerg Bruehe
2002-07-02 13:01 ` Christian Iseli
  -- strict thread matches above, loose matches on Subject: below --
2002-07-02 13:10 Peter Petrakis
2002-07-08 22:54 Donsbach, Jeff
2002-07-09  2:42 ` Alvin Starr

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