On Thu, Oct 13, 2011 at 07:24:12PM +0200, Jörg F. Wittenberger wrote:
> IMHO the moral of the story: Never trust you C compiler too much.
> 

I've had to get more familiar with gcc's -f flag, as the years have
gone by.  '-fno-strict-aliasing' is one that I've personally needed
(and chicken requires too, I believe) for some time now, and
variously I've had to turn those on and off based on writing C that
was a little too comfortable with the underlying machine
architecture.

A favorite trick of mine, for instance:

  struct string {
                size_t string_size;
                char   string_buffer[1]; /* note the single character string */
        }

Where I then malloc 'sizeof(struct string)+strlen(str)' all as one
block of memory and write the string past the end of the struct.[1]

You might find a wonderful playground of debugging potential if you
try this code fiddling with your -f options: start with the ones
that get defined with -O3, particularly those that aren't defined
in -O2.

-Alan

1: this stores both the size of the string and an extra character
   for the null pointer, which I do on purpose.
-- 
.i ma'a lo bradi cu penmi gi'e du

_______________________________________________
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to