Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-crg!styx!ames!ucbcad!ucbvax!decvax!mcnc!rti-sel!dg_rtp!throopw From: throopw@dg_rtp.UUCP (Wayne Throop) Newsgroups: comp.lang.c Subject: Re: pointers to arrays Message-ID: <717@dg_rtp.UUCP> Date: Tue, 25-Nov-86 18:12:51 EST Article-I.D.: dg_rtp.717 Posted: Tue Nov 25 18:12:51 1986 Date-Received: Wed, 26-Nov-86 19:59:33 EST References: <273@bms-at.UUCP> <1138@genrad.UUCP> <274@bms-at.UUCP> Lines: 48 Summary: Subtle note about &array under X3J11, and another method Stuart coded an example that "ought to work" under X3J11 C like so: > #include > jmp_buf *envptr; > void f(){ > jmp_buf local_env; > envptr = &local_env; > if (!setjmp(local_env)) { > /* . . . */ > } > } Couple of points. A longjmp to the envptr, coded like so: longjmp( envptr, 1 ); would be type incorrect, since envptr has type (jmp_buf *) (that is, type (int (*)[N])), and longjmp expects type a promoted jmp_buf type (that is, type (int *)). The longjmp ought to be coded: longjmp( *envptr, 1 ); Note that Stuart wanted a "better way" to code all this under current, pre X3J11 C. I note that if you don't mind the sleaziness of knowing that jmp_buf is really an array, and what element type jmp_buf has (int, in most cases), you can code it like so: #include int *envptr; void f(){ jmp_buf local_env; envptr = local_env; if (!setjmp(local_env)) { /* . . . */ } } And then, the longjmp becomes just longjmp( envptr, 1 ); I hope everybody sees why this works. -- A program without a loop and a structured variable isn't worth writing. --- Alan J. Perlis -- Wayne Throop !mcnc!rti-sel!dg_rtp!throopw