precedence lossage
precedence lossage
/pre's*-dens los'*j/ a c coding error in an expression due to unintended grouping of arithmetic or logical operators. used especially of certain common coding errors in c due to the nonintuitively low precedence levels of "&", "|", "^", ">". for example, the following c expression, intended to test the least significant bit of x,
>". for example, the following c expression, intended to test the least significant bit of x,
precedence lossage
/pre's*-dens los'*j/ A
C coding error in an expression due to unintended grouping of arithmetic or logical operators. Used especially of certain common coding errors in
C due to the nonintuitively low precedence levels of "&", "|", "^", "" and "". For example, the following C expression, intended to test the least significant bit of x,
x & 1 == 0
is parsed as
x & (1 == 0)
which the compiler would probably evaluate at compile-time to
(x & 0)
and then to 0.
Precedence lossage can always be avoided by suitable use of parentheses. For this reason, some
C programmers deliberately ignore the language's precedence hierarchy and parenthesise defensively.
Lisp fans enjoy pointing out that this can't happen in *their* favourite language, which eschews precedence entirely, requiring one to use explicit parentheses everywhere.
Other sources of
bugs include
aliasing bug,
memory leak,
memory smash,
smash the stack,
fandango on core,
overrun screw.
[
Jargon File]
(1994-12-16)
(c) Copyright 1993 by Denis Howe
precedence lossage
/pre's*-dens los'*j/ n. [C programmers] Coding error in an expression due to unexpected grouping of arithmetic or logical operators by the compiler. Used esp. of certain common coding errors in C due to the nonintuitively low precedence levels of &, |, ^, <<, and >> (for this reason, experienced C programmers deliberately forget the language's
baroque precedence hierarchy and parenthesize defensively). Can always be avoided by suitable use of parentheses.
LISP fans enjoy pointing out that this can't happen in their favorite language, which eschews precedence entirely, requiring one to use explicit parentheses everywhere. See
aliasing bug,
memory leak,
memory smash,
smash the stack,
fandango on core,
overrun screw.