This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Is it a bug or a feature?
- To: gcc-bugs at gcc dot gnu dot org
- Subject: Is it a bug or a feature?
- From: <apdim at kythira dot softlab dot tuc dot gr>
- Date: Sat, 7 Oct 2000 20:17:13 +0300 (EEST)
I think I got one
Apostolos
[apdim@kythira ~]$ rpm -q gcc gcc-c++
gcc-2.96-54
gcc-c++-2.96-54
[apdim@kythira ~]$ g++ -c gcc-segv.C
gcc-segv.C: In function `void solve ()':
gcc-segv.C:110: parse error before `.'
gcc-segv.C:107: Internal error: Segmentation fault.
Please submit a full bug report.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
#include <iostream.h>
#include <string.h>
const int base=10;
struct verylong
{
int n[1100], l;
void zero() { l=0; }
void print()
{ for(int i=l-1;i>=0;i--) cout << n[i]; }
void operator+=(verylong &t)
{
int p=0, c=0;
while(p<l || p<t.l || c!=0)
{
if(p >= l) n[p] = 0;
if(p >= t.l) t.n[p] = 0;
n[p] = n[p] + t.n[p] + c;
c = n[p] / base;
n[p] = n[p] % base;
p++;
}
l = p;
}
void operator*=(int t)
{
int p=0, c=0;
while(p<l || c!=0)
{
if(p >= l) n[p] = 0;
n[p] = n[p] * t + c;
c = n[p] / base;
n[p] = n[p] % base;
p++;
}
l = p;
}
void operator=(verylong &t)
{ l = t.l; for(int i=0;i<l;i++) n[i] = t.n[i]; }
void operator=(int k)
{ l=0; while(k>0) { n[l++] = k % base; k /= base; } }
void operator=(char *str)
{
l = strlen(str);
for(int i=0;i<l;i++) n[i] = str[l-1-i]-'0';
}
};
int cmp(verylong &a, verylong &b)
{
if(a.l != b.l) return 0;
for(int i=a.l-1;i>=0;i--) if(a.n[i] != b.n[i]) return a.n[i]-b.n[i];
return 1;
}
verylong r,x,y;
void
mul(verylong a, verylong b)
{
r = 0;
for(int i=0;i<b.l;i++)
{
verylong t; t = a; t *= b.n[i];
r += t;
a *= 10;
}
}
void
solve()
{
int c;
x = 1;
do
{
mul(x,x);
c = cmp(r,y);
}
while(c<0)
r.print();
cout << "\n";
}
main()
{
int tc;
cin >> tc;
for(int i=0;i<tc;i++)
{
char s[1200];
cin >> s;
if(i!=0) cout << "\n";
y = s;
solve();
}
}