Scholarly Resources for CompSci Undergrads

C Programming Language

Errata lists for K&R II

Correction to Section A7.8 (shift operators)

[Note: Section A7.8 is on page 206.]

From: scampi@dev.null (Mathew Hendry)
Newsgroups: comp.lang.c
Subject: Differences between K&R2 C and ISO/ANSI C
Date: Sat, 22 Nov 1997 00:32:13
Message-ID: <19971122.62CFD0.A38@am088.du.pipex.com>

I was under the impression that K&R2 was based directly on the ANSI/ISO
Standard, but apparently not.

K&R2, §A7.8, Shift Operators:
> [...]
>
> The _result_ is undefined if the right operand is negative, or greater than
> or equal to the number of bits in the left expression's type.
>
> [...]

ANSI/ISO 9899-1990, §6.3.7, Bitwise shift operators:
> [...]
>
> If the value of the right operand is negative or is greater than or equal to
> the width in bits of the promoted left operand, the _behaviour_ is
> undefined.
>
> [...]

(my emphasis in both cases)

Why the discrepancy, and are there any more?

-- 
           Mathew Hendry (actually at dial.pipex.com, not dev.null)
                                                                            --