🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6186

casting as lvalue, inconsistency

#6186
From: Ori Dvir
Date: Mon, 25 Nov 1996 00:00
30 lines
1099 bytes

Hi, 
I have a problem: inconsistent treetment of cast expressions.

Here is the program p1.c: 

int * int_ptr;
short * short_ptr;
char * char_ptr;

f1()
{
    ((char *)(int_ptr)) += 4;
    ((char *)(short_ptr)) += 4;
    ((char *)(char_ptr)) += 4;
}

gcc -pedantic p1.c

p1.c: In function `f1':
p1.c:7: warning: ANSI C forbids use of cast expressions as lvalues
p1.c:8: warning: ANSI C forbids use of cast expressions as lvalues
p1.c:9: invalid lvalue in assigmnet

In the first two cases a warning is issued, and the last case causes an error.
I'm using gcc 2.7.2.
What do you think?

Ori dvir : orid@taux01.nsc.com
Technical Details
Message-ID: <9611250651.AA03008@tasu5k.nsc.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,da499247880286ca,start
X-Google-Attributes: gid113d02,public
From: orid@taux01.nsc.com (Ori Dvir)
Subject: casting as lvalue, inconsistency
Date: 1996/11/25
Message-ID: <9611250651.AA03008@tasu5k.nsc.com>
X-Deja-AN: 198546318
sender: bug-gcc-request@prep.ai.mit.edu
x-gateway: relay7.UU.NET from bug-gcc to gnu.gcc.bug; Mon, 25 Nov 1996 01:52:21 EST
newsgroups: gnu.gcc.bug