syntax highlight

Friday, 26 March 2010

Reading Berkeley's FM

I got this from Oracle Berkely DB's FM:

  skey->size = sizeof((struct student_record *)pdata->data)->last_name;

Take a good look at that pice of code:

  a_number = sizeof((T*)pdata->data)->last_name;

Again:

  a_number = sizeof(Whatever)->field;

Wait a minute. typeof(sizeof(x)) == const unsigned int. Right? So, again:

  a_number = 42->field;

There's no way that first line can compile. Go and check it (in the example, not the last line please). I'll wait. Done? Yeap, I was surprised to, it does indeed compile. Mi first reaction towards this discovery went something like this:

What is going on there? It took me a while to figure out how evil Berkely 's manual can be. The answer next time.

1 comment: