Re: MSEC_TO_JIFFIES is messed up...

From: Paul Wagland (paul_at_wagland.net)
Date: 05/16/04

  • Next message: Russell King: "kernel BUG at drivers/block/ll_rw_blk.c:277!"
    Date:	Sun, 16 May 2004 14:10:06 +0200
    To: Chris Wedgwood <cw@f00f.org>
    
    
    

    On May 16, 2004, at 5:48, Chris Wedgwood wrote:

    > On Wed, May 12, 2004 at 11:55:18PM +0200, Andreas Schwab wrote:
    >
    >> Signed integer overflow is undefined in C, so the compiler is
    >> allowed to assume it does not happen.
    >
    > Really?
    >
    > Just because something is undefined assuming it never happens is a bit
    > of a leap of faith IMO.

    More precisely, if something has undefined semantics then the compiler
    is allowed to do whatever it likes. Normally the compiler will try to
    do "what's right", but if they have an optimisation opportunity then
    they will normally take it.

    In other words by assuming it "doesn't happen" they get to perform an
    optimisation that they could not do otherwise, and they get to perform
    "correctly" in an undefined way when the overflow would happen.

    Cheers,
    Paul

    
    

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/



  • Next message: Russell King: "kernel BUG at drivers/block/ll_rw_blk.c:277!"

    Relevant Pages

    • Re: MSEC_TO_JIFFIES is messed up...
      ... >> If gcc really optimizes that to just the identity function, ... > Signed integer overflow is undefined in C, so the compiler is allowed to ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: Types
      ... A machine has no concept of type, everything is just a sequence of ... the compiler to discover a lot of errors during the compilation ... runtime errors that can appear in C during the runtime in the primitive ...
      (comp.lang.c)
    • Re: [PATCH] fadvise(2) system call
      ... On Wednesday, November 02, 2011 2:11:41 pm Jilles Tjoelker wrote: ... Signed integer overflow is undefined behaviour; ... end + 1 without checking that end!= OFF_MAX, the compiler may assume ... John Baldwin ...
      (freebsd-arch)
    • Re: [PATCH] fadvise(2) system call
      ... Signed integer overflow is undefined behaviour; ... end + 1 without checking that end!= OFF_MAX, the compiler may assume ... Jilles Tjoelker ...
      (freebsd-arch)
    • Re: [discuss] booting a kernel compiled with -mregparm=0
      ... > this one) and even if GCC produced valid code by miracle, ... That's the default for a 'C' compiler (not to pass parameters ... This forced some parameters to be passed in registers, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)