[gmx-users] intel compiler + amd64: help needed.

David Mathog mathog at caltech.edu
Wed May 31 20:12:54 CEST 2006

David van der Spoel wrote:

> The mknb_func.coul is of another type (a subset of int) there you can 
> give its value to an integer, but not necessarily the other way around.
> I find it very unlikely that this would crash the program. 

The enum and int variables should be the same size so the
act of storing one in the other will not of itself crash
the program.  However subsequent code using that value could
easily result in a boom, in particular through an unhandled
enum case at higher optimization levels.  For instance, if the
compiler produces an object something like this pseudocode:

 /* no check for enum range */
    a=b;  /*a is enum range 0->6 but b 20 */
    jumpto offset + a*4;
offset+0: /* valid code */
offset+4; /* valid code */
offset+8; /* valid code */
offset+80; /* who knows what might be here */
           /* BOOM! */

The compiler is free to use any method it wants for a 
switch{} construct, especially if there is no default case
at the bottom to catch problems like this.


David Mathog
mathog at caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech

More information about the gromacs.org_gmx-users mailing list