#1230 Can't assign hex value to a double (with -ansi)

OTHER
closed
nobody
gcc (462)
works-for-me
User_Error
2013-01-31
2008-12-30
Sisyphus
No

Hi,

I'm using gcc version 3.4.5 (mingw special) with version 3.15.1 of the mingw runtime package - on Windows XP and Windows Vista.

The following is as I expect:

######################
C:\_32\c>type bug.c
#include <stdio.h>
#include <stdlib.h>

int main(void) {
double a = 0x123.1P-02;
printf("%f\n", a);
return 0;
}

C:\_32\c>gcc -o bug.exe bug.c

C:\_32\c>bug
72.765625

C:\_32\c>
######################

But if I try to compile the same source using the -ansi switch, the program fails to build:

######################
C:\_32\c>gcc -ansi -o bug.exe bug.c
bug.c:5:16: exponent has no digits

C:\_32\c>
######################

I'm not exactly sure how MinGW is supposed to react to doubles being assigned a hex value, but the differing behaviour looks buggy to me. (Apologies if I'm wrong about that.)

Cheers,
Rob

Discussion

  • Danny Smith

    Danny Smith - 2008-12-31
    • labels: 104601 --> gcc
    • status: open --> closed-works-for-me
     
  • Danny Smith

    Danny Smith - 2008-12-31

    -ansi switch enforces only C89 standard. hex float was introduced with ISO C99.
    Do this:
    gcc -std=c99 -o bug.exe bug.c

     
  • Earnie Boyd

    Earnie Boyd - 2013-01-31
    • status: closed-works-for-me --> closed
    • resolution: --> works-for-me
    • category: --> User_Error
    • milestone: --> OTHER
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks