Re: bug with -O2 in g++ Debian 4.0.2-9 ?

2006-02-23 Thread Digvijoy Chatterjee

#include

using namespace std;
class Rational
{

  int numerator;
  int denominator;
public:
  int GetNum ()
  {
return numerator;
  }
  int GetDen ()
  {
return denominator;
  }
  void setNum (int numer)
  {
numerator = numer;
  }

  void setDen (int den)
  {
denominator = den;
  }

  int gcd (int i1, int i2) 
  {
if (i2 == 0)
  return i1;
else
  return gcd (i2, i1 % i2);
  }
public :
  Rational (float f)
  {
int denom = 1;
while (((int) f  -  f)!= 0) 
  {
f *= 10;
denom *= 10;
  }
int Gcd = gcd (int (f), denom); 
numerator = f / Gcd;
cout < Here is the faulty program (this kind of code is generated by
> http://www.swig.org):
> 
> /// Start ///
> #include 
> 
> int main(void)
> {
> long long a = 0xL;
> long long b = 0;
> void ** aa=(void **)(void *)&a;
> void ** ab=(void **)(void *)&b;
> *ab = *aa;
> printf("in: %llX, out: %llX\n", a, b);
> return 0;
> }
> /// End ///
> 
> The output for the following version is:
> (Debian 1:3.3.6-12) g++ in: , out: 
> (Debian 1:3.3.6-12) g++ -O1 in: , out: 
> (Debian 1:3.3.6-12) g++ -O2 in: , out: 
> (Debian 4.0.2-9) g++in: , out: 
> (Debian 4.0.2-9) g++ -O1in: , out: 
> (Debian 4.0.2-9) g++ -O2in: , out: 0
> 
> So there is something wrong with g++ -O2 (Debian 4.0.2-9). Is this program 
> wrong
> or is this a bug ?
> 
> Regards,
> 
> Jerome
-- 
Thanks and Regards
Digvijoy Chatterjee

Please Visit http://indra/LiMS and start your Linux Journey


 CAUTION - Disclaimer *
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are 
not to copy, disclose, or distribute this e-mail or its contents to any other 
person and any such actions are unlawful. This e-mail may contain viruses. 
Infosys has taken every reasonable precaution to minimize this risk, but is not 
liable for any damage you may sustain as a result of any virus in this e-mail. 
You should carry out your own virus checks before opening the e-mail or 
attachment. Infosys reserves the right to monitor and review the content of all 
messages sent to or from this e-mail address. Messages sent to or from this 
e-mail address may be stored on the Infosys e-mail system.
***INFOSYS End of Disclaimer INFOSYS***


Re: bug with -O2 in g++ Debian 4.0.2-9 ?

2006-02-23 Thread Digvijoy Chatterjee

I am using g++ 4.0.2 on Suse-10
On Thu, 2006-02-23 at 15:50 +0530, Digvijoy Chatterjee wrote:
> #include
> 
> using namespace std;
> class Rational
> {
> 
>   int numerator;
>   int denominator;
> public:
>   int GetNum ()
>   {
> return numerator;
>   }
>   int GetDen ()
>   {
> return denominator;
>   }
>   void setNum (int numer)
>   {
> numerator = numer;
>   }
> 
>   void setDen (int den)
>   {
> denominator = den;
>   }
> 
>   int gcd (int i1, int i2) 
>   {
> if (i2 == 0)
>   return i1;
> else
>   return gcd (i2, i1 % i2);
>   }
> public :
>   Rational (float f)
>   {
> int denom = 1;
> while (((int) f  -  f)!= 0) 
>   {
> f *= 10;
> denom *= 10;
>   }
> int Gcd = gcd (int (f), denom); 
> numerator = f / Gcd;
> cout < denominator = denom / Gcd;
> cout<<"-"< cout <   }
>  
> };
> 
> int
> main (int argc, char **argv)
> {
>   Rational r1 = Rational (.4537f);
> }
> 
> 
> -
> This runs successfully with:
> g++ without any optimization  ,
> but with -O or -02 or -03  the executable just hangs forever
> 
> 
> On Thu, 2006-02-23 at 10:56 +0100, Jerome Robert wrote:
> > Here is the faulty program (this kind of code is generated by
> > http://www.swig.org):
> > 
> > /// Start ///
> > #include 
> > 
> > int main(void)
> > {
> > long long a = 0xL;
> > long long b = 0;
> > void ** aa=(void **)(void *)&a;
> > void ** ab=(void **)(void *)&b;
> > *ab = *aa;
> > printf("in: %llX, out: %llX\n", a, b);
> > return 0;
> > }
> > /// End ///
> > 
> > The output for the following version is:
> > (Debian 1:3.3.6-12) g++ in: , out: 
> > (Debian 1:3.3.6-12) g++ -O1 in: , out: 
> > (Debian 1:3.3.6-12) g++ -O2 in: 7777, out: 
> > (Debian 4.0.2-9) g++in: , out: 
> > (Debian 4.0.2-9) g++ -O1in: , out: 
> > (Debian 4.0.2-9) g++ -O2in: , out: 0
> > 
> > So there is something wrong with g++ -O2 (Debian 4.0.2-9). Is this program 
> > wrong
> > or is this a bug ?
> > 
> > Regards,
> > 
> > Jerome
-- 
Thanks and Regards
Digvijoy Chatterjee

Please Visit http://indra/LiMS and start your Linux Journey


 CAUTION - Disclaimer *
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are 
not to copy, disclose, or distribute this e-mail or its contents to any other 
person and any such actions are unlawful. This e-mail may contain viruses. 
Infosys has taken every reasonable precaution to minimize this risk, but is not 
liable for any damage you may sustain as a result of any virus in this e-mail. 
You should carry out your own virus checks before opening the e-mail or 
attachment. Infosys reserves the right to monitor and review the content of all 
messages sent to or from this e-mail address. Messages sent to or from this 
e-mail address may be stored on the Infosys e-mail system.
***INFOSYS End of Disclaimer INFOSYS***


Re: bug with -O2 in g++ Debian 4.0.2-9 ?

2006-02-23 Thread Digvijoy Chatterjee

On Thu, 2006-02-23 at 13:54 +0100, Richard Guenther wrote:
> > This runs successfully with:
> > g++ without any optimization  ,
> > but with -O or -02 or -03  the executable just hangs forever
> 
> See PR323 - this is expected behavior.
> 
> Richard.
> 
What is PR323 ,is it some page in the manual /or gcc info ?  Please
articulate
-- 
Thanks and Regards
Digvijoy Chatterjee

Please Visit http://indra/LiMS and start your Linux Journey


 CAUTION - Disclaimer *
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are 
not to copy, disclose, or distribute this e-mail or its contents to any other 
person and any such actions are unlawful. This e-mail may contain viruses. 
Infosys has taken every reasonable precaution to minimize this risk, but is not 
liable for any damage you may sustain as a result of any virus in this e-mail. 
You should carry out your own virus checks before opening the e-mail or 
attachment. Infosys reserves the right to monitor and review the content of all 
messages sent to or from this e-mail address. Messages sent to or from this 
e-mail address may be stored on the Infosys e-mail system.
***INFOSYS End of Disclaimer INFOSYS***