Hugh Leather wrote: > Hi, > > I am trying to add a new destructor function to object files I > compile. I'm doing this to instrument programs and then, once the > program has finished I want to print out the statistics I've gathered. > So, just before pass 'remove_useless_stmts' is called on each function > I try to create a static destructor which will print stats for the > current function (and obviously, I don't do it on the functions just > created). > > Below I've put a simpler form, which should work for a one function > program. Calling createFnDecl() creates a new function called > __my_new_function. It should print "It worked!" when the program exits. > Now, with compiler flag -O0, this works just fine, but with -O1 or > above it seg faults the compiler. > > Can anyone tell me what I'm doing wrong?
Nothing obvious to me. Did you debug the point at which the segfault happened? Andrew.