Article View: net.bugs.2bsd
Article #233C Compiler Bug
From: keenan
Date: Tue, 28 May 1985 22:43
Date: Tue, 28 May 1985 22:43
31 lines
1476 bytes
1476 bytes
Here is a small program that demonstrates what I think is a bug in the
BSD2.9 C compiler. I guess its not appropriate to use a long as the
index to an array, but it should just be cast to an integer, and not
affect the postdecrement. Instead the decrement treats the variable as
an integer. The results are also presented. Is this a bug, or is my
code just incorrect?
#include <stdio.h>
int arr[100];
int x;
long p_end;
main()
{
printf("Autodecrement inside array reference\n");
p_end = 0l;
printf("before %ld\n", p_end);
x = arr[p_end--];
printf("after %ld\n", p_end);
}
++++++++++++++++++++++++++ OUTPUT +++++++++++++++++++++++++
Autodecrement inside array reference
before 0
after 65535
--keenan ross UUCP: {bellcore,ihnp4}!inmet!keenan
Intermetrics, Inc. INTERNET: ima!inmet!keenan@CCA-UNIX.ARPA
733 Concord Ave.
Cambridge, MA 02138 PHONE: (617) 661-1840
Technical Details
Message-ID:
<2900001@inmet.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!cca!inmet!keenanShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.6.2.16 $; site inmet.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!cca!inmet!keenan From: keenan@inmet.UUCP Newsgroups: net.bugs.2bsd Subject: C Compiler Bug Message-ID: <2900001@inmet.UUCP> Date: Tue, 28-May-85 18:43:00 EDT Article-I.D.: inmet.2900001 Posted: Tue May 28 18:43:00 1985 Date-Received: Fri, 31-May-85 04:45:23 EDT Lines: 31 Nf-ID: #N:inmet:2900001:000:886 Nf-From: inmet!keenan May 28 18:43:00 1985