Path: utzoo!utgpu!watmath!att!pacbell!ames!bionet!csd4.milw.wisc.edu!cs.utexas.edu!uunet!mcvax!kth!sunic!liuida!mikpe From: mikpe@majestix.ida.liu.se (Mikael Pettersson) Newsgroups: comp.lang.c Subject: What is the scope of "type-name" in a cast expression? Message-ID: <1324@majestix.ida.liu.se> Date: 8 Aug 89 01:04:00 GMT Organization: CIS Dept, Univ of Linkoping, Sweden Lines: 32 I have a question for those who know the details about C declarations: What is the scope of the "type-name" in a cast expression? My impression is that the scope should be the entire surrounding expression (but not any further), but the compilers I've tried [PCC and GCC on a Sun3] both in fact make the type visible from the enclosing statement and downwards to the end of the {}-block. Example of code I think should be rejected: --huh.c-- /* accepted by PCC and GCC */ f() { int i; *(enum { foo, bar, bletch } *)&i = bar; i = foo; /* ?? */ } g() { int ia[2]; ((struct foo { int i,j; } *)ia)->i = 99; ia[1] = sizeof (struct foo); /* ?? */ } -- AdvTHANX for any references to the appropriate "chapter and verse". [RTFM? I have looked in both "The C Programming Language - Reference Manual" (UNIX PS1 4.3BSD) (essentially a reprint from K&R1) and "C: A Reference Manual, 2nd Ed." (Harbison&Steele) and found nil :-(] -- Mikael Pettersson, Dept of Comp & Info Sci, University of Linkoping, Sweden email: mpe@ida.liu.se or ..!{mcvax,munnari,uunet}!enea!liuida!mpe