TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Thomas Seeling
from: Daniel Lynes
date: 1996-07-25 02:01:40
subject: My last post about the violation ac

Hello Thomas!

22 Jul 96 10:56, Thomas Seeling wrote to Daniel Lynes:

 TS> void foo(int *x) {
 TS>   int z;

 TS> /* this is ok, but senseless */
 TS>   *x++;

test.c(5): Warning! W302: Expression is only useful for its side effects

 TS> /* this is illegal, since x does not contain a "legal" pointer */
 TS>   z=*x;

However, the compiler does not spit out an error for this; nor, do I see why it
should.  Basically you're assigning the value contained in the pointer x, to
the variable, z.  Why is this illegal?  Did you try compiling it?

When the *x++; is commented out, z=1.  When the *x++; is not commented out,
z=71565.  However, z I don't believe is guaranteed to be any specific number,
lending to the fact that *x++; is only useful for its side effects.  i.e.  its
behaviour is unpredictable.

Daniel

internet:  dbl{at}eznet.ca

... Children have more need of models than of critics.

--- GoldED/2 2.42.G0615+
* Origin: Enitharmon/2 Beta Home Site 604-527-0195 (1:153/8028)
SEEN-BY: 50/99 270/101 620/243 625/100 711/401 409 410 413 430 808 809 934
SEEN-BY: 711/955 712/407 515 624 628 713/888 800/1
@PATH: 153/8028 831 800 270/101 712/515 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.