Re: [C++] Possible GCC bug

2012-11-14 Thread Ulf Magnusson
On Wed, Nov 14, 2012 at 6:10 PM, Piotr Wyderski wrote: > The following snippet: > > class A {}; > class B : public A { > >typedef A super; > > public: > >class X {}; > }; > > > class C : public B { > >typedef B super; > >class X : public super::X { > > typedef super::X super;

Re: Option to make unsigned->signed conversion always well-defined?

2011-10-07 Thread Ulf Magnusson
On Fri, Oct 7, 2011 at 7:35 PM, Florian Weimer wrote: > * Ulf Magnusson: > >> Are you thinking of something like this? >> >> bool overflow_bit2(unsigned int a, unsigned int b) { >>     const unsigned int ashift = a << 24; >>     const unsigned int bshif

Re: Option to make unsigned->signed conversion always well-defined?

2011-10-07 Thread Ulf Magnusson
On Thu, Oct 6, 2011 at 11:31 PM, Florian Weimer wrote: > * Ulf Magnusson: > >> I've been experimenting with different methods for emulating the >> signed overflow of an 8-bit CPU. The method I've found that seems to >> generate the most efficient code on both

Re: Option to make unsigned->signed conversion always well-defined?

2011-10-06 Thread Ulf Magnusson
(I'll cross-post this to gcc and keep it on gcc-help after that.) On Thu, Oct 6, 2011 at 4:46 PM, Andrew Haley wrote: > > inline int8_t as_signed_8 (unsigned int a) { > a &= 0xff; > return a & 0x80 ? (int)a - 0x100 : a; > } > > int overflow(unsigned int a, unsigned int b) { > int sum = as_sign

Re: Option to make unsigned->signed conversion always well-defined?

2011-10-06 Thread Ulf Magnusson
On Thu, Oct 6, 2011 at 11:04 AM, Miles Bader wrote: > Ulf Magnusson writes: >> Might as well do >> >> bool overflowbit(unsigned int a, unsigned int b) { >>     const unsigned int sum = a + b; >>     return (a ^ b) & ~(a ^ sum) & 0x80; >> } >>

Re: Option to make unsigned->signed conversion always well-defined?

2011-10-06 Thread Ulf Magnusson
On Thu, Oct 6, 2011 at 10:25 AM, Ulf Magnusson wrote: > On Thu, Oct 6, 2011 at 12:55 AM, Pedro Pedruzzi > wrote: >> Em 05-10-2011 17:11, Ulf Magnusson escreveu: >>> Hi, >>> >>> I've been experimenting with different methods for emulating the >>

Re: Option to make unsigned->signed conversion always well-defined?

2011-10-06 Thread Ulf Magnusson
On Thu, Oct 6, 2011 at 12:55 AM, Pedro Pedruzzi wrote: > Em 05-10-2011 17:11, Ulf Magnusson escreveu: >> Hi, >> >> I've been experimenting with different methods for emulating the >> signed overflow of an 8-bit CPU. > > You would like to check whether a

Re: Option to make unsigned->signed conversion always well-defined?

2011-10-05 Thread Ulf Magnusson
On Wed, Oct 5, 2011 at 10:11 PM, Ulf Magnusson wrote: > Hi, > > I've been experimenting with different methods for emulating the > signed overflow of an 8-bit CPU. The method I've found that seems to > generate the most efficient code on both ARM and x86 is > &g

Option to make unsigned->signed conversion always well-defined?

2011-10-05 Thread Ulf Magnusson
Hi, I've been experimenting with different methods for emulating the signed overflow of an 8-bit CPU. The method I've found that seems to generate the most efficient code on both ARM and x86 is bool overflow(unsigned int a, unsigned int b) { const unsigned int sum = (int8_t)a + (int8_t)b;

Re: Suboptimal __restrict optimization?

2011-10-04 Thread Ulf Magnusson
On Mon, Oct 3, 2011 at 10:22 PM, Ian Lance Taylor wrote: > Ulf Magnusson writes: > >> Is there some reason why GCC couldn't generate this code for the first >> version of C::f()? Is this a failure of optimization, or am I missing >> something in how __restricted

Suboptimal __restrict optimization?

2011-10-01 Thread Ulf Magnusson
Hi, Given the code class C { void f(int *p); int q; }; void C::f(int * __restrict p) __restrict { q += 10; *p = 7; q += 10; } g++ 4.5.2 with -O3 generates the following for C::f() (prologue and epilogue omitted): mov0x8(%ebp),%eax // eax = this (= &q) mov0xc(%ebp),%ecx // e

Re: Finding canonical names of systems

2006-11-29 Thread Ulf Magnusson
On 11/29/06, Michael Eager <[EMAIL PROTECTED]> wrote: Ulf Magnusson wrote: > While searching for an answer, I noticed that lots of people seem > to have had problems with cross-compilation that to me look more > like problems in the documentation, which I find a bit sad. Rather

Re: Finding canonical names of systems

2006-11-29 Thread Ulf Magnusson
On 11/29/06, Michael Eager <[EMAIL PROTECTED]> wrote: Ulf Magnusson wrote: > How are you supposed to find the canonical name of a system (of known > type) in CPU-Vendor-OS form in the general case? If you have access to > a system of that particular type, you can run config.gues

Re: Finding canonical names of systems

2006-11-28 Thread Ulf Magnusson
On 11/28/06, Mike Stump <[EMAIL PROTECTED]> wrote: [ first, this is the wrong list to ask such question, gcc-help is the right one ] On Nov 27, 2006, at 7:25 PM, Ulf Magnusson wrote: > How are you supposed to find the canonical name of a system (of > known type) in CPU-Vendor-OS

Finding canonical names of systems

2006-11-27 Thread Ulf Magnusson
rom a documentation perspective. Is there any other way to get a list mapping CPU's, Vendors and OS's to their canonical strings? If there isn't, I think it's making things much more complicated than they should be. /Ulf Magnusson