Re: forced casts question
Etienne Gagnon <[email protected]> Wed, 19 Jan 2005 00:11:40 -0500
| Newsgroups | gmane.comp.java.vm.sablevm.devel |
|---|---|
| Organization | UQAM |
| Message-ID | <[email protected]> |
Chris Pickett wrote: > - _svmt_stack_frame *frame = (_svmt_stack_frame *) > + _svmt_stack_frame *frame = (_svmt_stack_frame *) (void *) > (((char *) env->stack.current_frame) + offset); > > I think this was to "eliminate tons of spurious warnings" (r3144), but > why were such things causing warnings? Isn't it good to let the > compiler help you catch casting errors? The casting error was about possible mi-alignment of the pointer, after casting. In this case, as SableVM's stack frame computations are always done such as to guarantee correct alignment, the warning was spurious. Such spurious warnings, when issued in great quantity, can hide real warnings. This is why I got rid of them using the ugly (and only) trick that allowed enabling GCC's cast warnings without being riddled with tons of spurious warnings. I did check every single cast before adding "(void *)", to make sure I was not actually hiding a real problem. Please note that for any new code, in general, it is *NOT* an accepted practice to write type casts directly in SableVM. One should instead add an entry in cast.list and use the generated _svmf_cast_XXX() function to do a cast. [I wonder if it would not be a good idea to even create special cast functions for computing the frame, local and stack pointers, and this centralize these dangerous hacks, while adding some additional type safety.] Etienne -- Etienne M. Gagnon, Ph.D. http://www.info2.uqam.ca/~egagnon/ SableVM: http://www.sablevm.org/ SableCC: http://www.sablecc.org/ _______________________________________________ SableVM-devel mailing list [email protected] http://sablevm.org/lists/control/listinfo/sablevm-devel
signature.asc
(application/pgp-signature, 256 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.5 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFB7ewTjyrJi4rH84gRArPkAJ4qe1cM4G4b5iHMUeJ54is2lX7xtgCfYbFj 8oIrIAMbRqGGpyH5JnNwJaw= =0KZP -----END PGP SIGNATURE-----