Free Downloads, Community Forum,
FAQs and Developer Resources


Make /Tools Your Home | Link to us

Today's posts | Posts since last visit | Most Active Topics

All Forums Register Login Search Subscriptions My Profile Inbox
Tool Warehouse FAQs Resources Help Member List Address Book Logout

Is this a known bug of c89/VC6?

 
Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [SFU / Interix / SUA Technology] >> Interix Advanced Forum >> Is this a known bug of c89/VC6? Page: [1]
Login
Message << Older Topic   Newer Topic >>
Is this a known bug of c89/VC6? - Jan. 17, '06, 6:26:44 PM   
jluis

 

Posts: 13
Joined: Oct. 18, '05,
Status: offline
Hi,
This is a test meant to try to isolate a real problem.
In both cases below the if tests should always give != 0
but when the macro definition is used I get NaN == 0
Here are the outputs

1. gcc test_nanVC.c -o test_nanVC
test_nanVC
x_dir = 2147483648.000000 x_indir = NaN
x_dir = 0 x_indir = 41e00000
Case Dir - Not-Equal zero
Case Indir - Not-Equal zero

2. c89 test_nanVC.c
a.out
x_dir = 2147483648.000000 x_indir = NaN
x_dir = 0 x_indir = 41e00000
Case Dir - Not-Equal zero
Case Indir - Equal zero

Is this a know bug of MSVC6 (the compiler I have installed)?

Thanks

J. Luis

/* test_nanVC.c */
#define GMT_make_fnan(x) (((unsigned int *) &x)[0] = 0x7fffffff)

#include <stdio.h>

int main(int argc, char **argv) {
float x_indir, x_dir;

x_dir = ((unsigned int *) &x_dir)[0] = 0x7fffffff;

GMT_make_fnan(x_indir);
fprintf(stderr,"x_dir = %f\tx_indir = %f\n",x_dir, x_indir);
fprintf(stderr,"x_dir = %0x\tx_indir = %0x\n",x_dir, x_indir);

if (x_dir == 0)
fprintf(stderr,"Case Dir - Equal zero\n");
else
fprintf(stderr,"Case Dir - Not-Equal zero\n");

if (x_indir == 0)
fprintf(stderr,"Case Indir - Equal zero\n");
else
fprintf(stderr,"Case Indir - Not-Equal zero\n");

return(0);
}
Post #: 1
RE: Is this a known bug of c89/VC6? - Jan. 17, '06, 6:38:44 PM   
markfunk

 

Posts: 623
Joined: Mar. 31, '03,
Status: offline
Looks like it.
Using VC7, I get:

x_dir = 2147483648.000000 x_indir = NaN
x_dir = 0 x_indir = 41e00000
Case Dir - Not-Equal zero
Case Indir - Not-Equal zero

(in reply to jluis)
Post #: 2
RE: Is this a known bug of c89/VC6? - Jan. 17, '06, 6:45:43 PM   
jluis

 

Posts: 13
Joined: Oct. 18, '05,
Status: offline
Thank you markfunk

(in reply to markfunk)
Post #: 3
Page:   [1]
All Forums >> [SFU / Interix / SUA Technology] >> Interix Advanced Forum >> Is this a known bug of c89/VC6? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Search All Forums -

Advanced search


SPONSORS



Forum Software © ASPPlayground.NET Advanced Edition 2.5 ANSI

0.031