🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3447

(no subject)

#3447
From: Daniel Wood
Date: Sun, 08 Oct 1995 01:17
32 lines
1397 bytes
The following:
	((char *)src)++;	/* src is an (int *) */
when compiled using Solaris SparcWorks 3.0.1, generates:
	"t.c", line 12: warning: a cast does not yield an lvalue

I fully understand why it makes no sense to say:

	(char *)src = x;

but, if the compiler thinks that it is stupid to interpret:

	((char *)src)++;
as:
	(char *)src = (char *)src + 1;

then why is it doing it, since I am intending:

	src = (char *)src + 1;

A cast on an operator like "++" should only be applied to the RHS.

What does the standard say?

The following isn't pretty but is the only why to get rid of the warning message:
	
*(char *)(src=(int *)((char *)src+1)) = *(char *)(dst=(int *)((char *)dst+1));		

--
If you want a fancy saying then go find yourself a poet.
If you want a bug cracked then you've come to the right place.

"The numbers speak to me" - 44 61 6E 20 57 6F 6F 64
Technical Details
Message-ID: <4578r1$jub@news.informix.com>
Path: arc1-ca.pugleaf.net!informix.com!news

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!informix.com!news
From: Daniel Wood <dwood>
Newsgroups: comp.std.c,comp.lang.c,comp.unix.solaris
Subject: (no subject)
Date: 8 Oct 1995 01:17:21 GMT
Organization: Informix Software, Inc. Menlo Park, CA 94025
Distribution: inet
Message-ID: <4578r1$jub@news.informix.com>
NNTP-Posting-Host: dwood.informix.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 1.1N (X11; I; SunOS 5.4 sun4m)
X-URL: news:comp.std.c