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


Groups > comp.lang.c++ > #10087 > unrolled thread

[floating-literal]

Started byMihai Vasilian <grayasm@gmail.com>
First post2011-09-13 14:53 -0700
Last post2011-09-14 01:53 -0500
Articles 3 — 3 participants

Back to article view | Back to comp.lang.c++


Contents

  [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

#10087 — [floating-literal]

FromMihai Vasilian <grayasm@gmail.com>
Date2011-09-13 14:53 -0700
Subject[floating-literal]
Message-ID<168e9a7a-b75a-4c6a-98b2-9eaee0beb948@glegroupsg2000goo.googlegroups.com>
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.

[toc] | [next] | [standalone]


#10088

Fromjacob navia <jacob@spamsink.net>
Date2011-09-14 00:29 +0200
Message-ID<4E6FD95A.5050500@spamsink.net>
In reply to#10087
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.


[toc] | [prev] | [next] | [standalone]


#10096

FromRobert Wessel <robertwessel2@yahoo.com>
Date2011-09-14 01:53 -0500
Message-ID<gdi077hc6nv7b436g41shpd91qb8aam2q3@4ax.com>
In reply to#10087
On Tue, 13 Sep 2011 14:53:37 -0700 (PDT), Mihai Vasilian
<grayasm@gmail.com> wrote:

>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 ?


It's apparently an implementation limit in MSVC.

Interestingly, it's not applied to identifiers (which is correct,
since the standard specifies "There is no specific limit on the
maximum length of an identifier", but the compiler may largely ignore
characters in identifiers after a certain point, but must accept long
ones - MSVC's documented significance limit is 257).

But nothing in the standard really speaks to the minimum allowable
length of other types of tokens, except for strings.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.c++


csiph-web