This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: [isocpp-parallel] Proposal for new memory_order_consume definition
- From: "Paul E. McKenney" <paulmck at linux dot vnet dot ibm dot com>
- To: Linus Torvalds <torvalds at linux-foundation dot org>
- Cc: linux-arch at vger dot kernel dot org, Jade Alglave <j dot alglave at ucl dot ac dot uk>, p796231 <Peter dot Sewell at cl dot cam dot ac dot uk>, gcc at gcc dot gnu dot org, llvm-dev at lists dot llvm dot org, Luc Maranget <luc dot maranget at inria dot fr>, mingo at kernel dot org, akpm at linux-foundation dot org, dhowells at redhat dot com, linux-kernel at vger dot kernel dot org, parallel at lists dot isocpp dot org, will dot deacon at arm dot com, peterz at infradead dot org, Ramana dot Radhakrishnan at arm dot com
- Date: Sat, 27 Feb 2016 15:10:33 -0800
- Subject: Re: [isocpp-parallel] Proposal for new memory_order_consume definition
- Authentication-results: sourceware.org; auth=none
- References: <20160218011033 dot GA1505 at linux dot vnet dot ibm dot com> <20160220021516 dot 4898897 dot 32908 dot 5212 at gmail dot com> <20160220195318 dot GF3522 at linux dot vnet dot ibm dot com> <CAPUmR1bw=N4NkjAK1zn_X0+84KEaEAM6HZCHZJy_txqC9hMgSg at mail dot gmail dot com> <20160227170615 dot GU3522 at linux dot vnet dot ibm dot com> <CA+55aFyHmykKc=YybJMo9ZUO352MY5noJVB4-K1Lkjmw4UHXfA at mail dot gmail dot com>
- Reply-to: paulmck at linux dot vnet dot ibm dot com
On Sat, Feb 27, 2016 at 11:16:51AM -0800, Linus Torvalds wrote:
> On Feb 27, 2016 09:06, "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> wrote:
> >
> >
> > But we do already have something very similar with signed integer
> > overflow. If the compiler can see a way to generate faster code that
> > does not handle the overflow case, then the semantics suddenly change
> > from twos-complement arithmetic to something very strange. The standard
> > does not specify all the ways that the implementation might deduce that
> > faster code can be generated by ignoring the overflow case, it instead
> > simply says that signed integer overflow invoked undefined behavior.
> >
> > And if that is a problem, you use unsigned integers instead of signed
> > integers.
>
> Actually, in the case of there Linux kernel we just tell the compiler to
> not be an ass. We use
>
> -fno-strict-overflow
That is the one!
> or something. I forget the exact compiler flag needed for "the standard is
> as broken piece of shit and made things undefined for very bad reasons".
>
> See also there idiotic standard C alias rules. Same deal.
For which we use -fno-strict-aliasing.
> So no, standards aren't that important. When the standards screw up, the
> right answer is not to turn the other cheek.
Agreed, hence my current (perhaps quixotic and insane) attempt to get
the standard to do something useful for dependency ordering. But if
that doesn't work, yes, a fallback position is to get the relevant
compilers to provide flags to avoid problematic behavior, similar to
-fno-strict-overflow.
Thanx, Paul
> And undefined behavior is pretty much *always* a sign of "the standard is
> wrong".
>
> Linus