Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #10088

Re: [floating-literal]

From jacob navia <jacob@spamsink.net>
Newsgroups comp.lang.c++
Subject Re: [floating-literal]
Date 2011-09-14 00:29 +0200
Organization lccwin
Message-ID <4E6FD95A.5050500@spamsink.net> (permalink)
References <168e9a7a-b75a-4c6a-98b2-9eaee0beb948@glegroupsg2000goo.googlegroups.com>

Show all headers | View raw


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.


Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[floating-literal] Mihai Vasilian <grayasm@gmail.com> - 2011-09-13 14:53 -0700
  Re: [floating-literal] jacob navia <jacob@spamsink.net> - 2011-09-14 00:29 +0200
  Re: [floating-literal] Robert Wessel <robertwessel2@yahoo.com> - 2011-09-14 01:53 -0500

csiph-web