[floating-literal]

M

Mihai Vasilian

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.
 
J

jacob navia

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top