[floating-literal]

Discussion in 'C++' started by Mihai Vasilian, Sep 13, 2011.

  1. Hello,

    I am trying to write a small lexer for source code. (something simple)
    I've been looking at the syntax of the "[floating-literal]:" in C++ ISO.
    I had this idea of testing with very long repetition of 1 in "[fractional-constant]"
    I compiled with VS2010 and the error is:
    "fatal error C1064: compiler limit : token overflowed internal buffer"

    C1064 is described as: "An identifier exceeds the length of the internal buffer used for identifiers. Shorten the name."

    ---code---
    #include <iostream>
    int main()
    {
    float f = 111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.e1;
    std::cout << f << std::endl;
    return 0;
    };
    ---end_of_code---


    So,
    1) is the length of the [digit-sequence] specified anywhere ? ISO/IEEE
    2) why GCC takes it without warning ?
    3) is this C1064 error coming possibly from the lexer of MS compiler front-end ? Do you think char id[130] (for an identifier) is large enough ?

    Thanks.
    Mihai.
     
    Mihai Vasilian, Sep 13, 2011
    #1
    1. Advertising

  2. Mihai Vasilian

    jacob navia Guest

    Le 13/09/11 23:53, Mihai Vasilian a écrit :
    > Hello,
    >
    > I am trying to write a small lexer for source code. (something simple)
    > I've been looking at the syntax of the "[floating-literal]:" in C++ ISO.
    > I had this idea of testing with very long repetition of 1 in "[fractional-constant]"
    > I compiled with VS2010 and the error is:
    > "fatal error C1064: compiler limit : token overflowed internal buffer"
    >
    > C1064 is described as: "An identifier exceeds the length of the internal buffer used for identifiers. Shorten the name."
    >
    > ---code---
    > #include<iostream>
    > int main()
    > {
    > float f = 111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111.e1;
    > std::cout<< f<< std::endl;
    > return 0;
    > };
    > ---end_of_code---
    >
    >
    > So,
    > 1) is the length of the [digit-sequence] specified anywhere ? ISO/IEEE


    I do not think so. The C standard doesn't mention it. I do not know
    about the C++ standard

    > 2) why GCC takes it without warning ?


    Because it is missing the diagnostic
    "Overflow in constant expression". A small bug.


    > 3) is this C1064 error coming possibly from the lexer of MS compiler front-end ?


    Very probably

    Do you think char id[130] (for an identifier) is large enough ?

    I think that the microsoft documentation is wrong. It is not
    an identifier since it begins with a number. It is a buffer
    for a number that overflows and I do think that 130 is enough
    for a number buffer. 130 character positions allow you a
    precision of 1e-130 what is WAAAAAAAAAY beyond the machine precision
    in ALL cases.


    The lcc-win compiler issues the warning
    "Overflow in constant expression"
    and generates infinity as gcc does.
     
    jacob navia, Sep 13, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    541
    Alf P. Steinbach
    Feb 4, 2008
  2. TimC
    Replies:
    6
    Views:
    2,120
    CBFalconer
    Mar 7, 2009
  3. TimC
    Replies:
    2
    Views:
    4,505
    James Kanze
    Mar 7, 2009
  4. Anonieko Ramos

    What's wrong with rpc-literal? Why use doc-literal?

    Anonieko Ramos, Sep 27, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    392
    Anonieko Ramos
    Sep 27, 2004
  5. teeshift
    Replies:
    2
    Views:
    274
    Chris Pearl
    Dec 1, 2006
Loading...

Share This Page