On Wed, Jul 9, 2008 at 5:49 PM, Chris Jefferson <chris@xxxxxxxxxxxxxxx> wrote: > 2008/7/9 James Gregory <james.jrg@xxxxxxxxx>: >> 4. Compile with gcc 4.2.3 (Ubuntu 64 bit), with optimization: my >> program freezes in a particular function >> 5. Compile with gcc 4.2.3 (Ubuntu 64 bit), with optimization, and >> include <iostream> at the top of the file where the function which >> freezes is defined: my program doesn't freeze Chris Jefferson suggested I add the compiler flag "-fdump-tree-all". I did this for the build which included iostream and the one which didn't, produced a diff of the final code produced for the problematic source file between each version, cropped it a bit, and came up with the following. I don't understand assembler, but the header file inclusion has clearly changed the code gcc produces. The obvious differences are: 1. The existence of the line "-Invalid sum of incoming frequencies 873, should be 0" in the freezing version 2. The replacement of this in the version which freezes: - const unsigned char * this___l_iterthis__I___M_currentthis____.4618; - const unsigned char * this___l_iterthis__I___M_currentthis____.4617; - const unsigned char * this___l_iterthis__I___M_currentthis____.4616; to this in the version which doesn't: + unsigned char temp.4650; + unsigned char temp.4649; + unsigned char temp.4648; Can anyone tell me what is going on here? --- AIInterpreter.cpp.102t.final_cleanup 2008-07-12 21:21:37.000000000 +0100 +++ ../nofreeze/AIInterpreter.cpp.102t.final_cleanup 2008-07-12 21:23:33.000000000 +0100 <snip> bool AIInterpreter::is_group_like_this(int, int, bool, bool) (this, n_side, n_group, discount_dead, discount_our) { - int stat_value.4637; - const unsigned char * this___l_iterthis__I___M_currentthis____.4618; - const unsigned char * this___l_iterthis__I___M_currentthis____.4617; - const unsigned char * this___l_iterthis__I___M_currentthis____.4616; + int stat_value.4653; + unsigned char temp.4650; + unsigned char temp.4649; + unsigned char temp.4648; int give_group; int give_side; - struct Group_Base * D.100623; - bool D.100627; + struct Group_Base * D.100677; + bool D.100681; size_t __n; - struct Group_Base * D.100588; - const unsigned char * D.86283; - const unsigned char & D.86265; - unsigned char D.86266; - const unsigned char & D.86197; - unsigned char D.86198; - const unsigned char & D.86143; - unsigned char D.86144; + struct Group_Base * D.100642; + const unsigned char * D.86304; + const unsigned char & D.86286; + unsigned char D.86287; + const unsigned char * D.86270; + const unsigned char & D.86218; + unsigned char D.86219; + const unsigned char * D.86202; + const unsigned char & D.86164; + unsigned char D.86165; + const unsigned char * D.86148; size_t __n; - struct Side * D.86086; + struct Side * D.86107; int second_value; const unsigned char operator_type; int stat_value; - const unsigned char & D.68774; - unsigned char D.68755; - int D.68741; + const unsigned char & D.68792; + unsigned char D.68773; + int D.68759; <bb 2>: - D.100588 = operator-> (&((sides.D.66353._M_impl._M_start + (struct Side *) ((long unsigned int) n_side * 256))->groups.D.33422._M_impl._M_start + (struct Group *) ((long unsigned int) n_group * 16))->h_group); - if (D.100588->alive) goto <L1>; else goto <L0>; + D.100642 = operator-> (&((sides.D.66353._M_impl._M_start + (struct Side *) ((long unsigned int) n_side * 256))->groups.D.33422._M_impl._M_start + (struct Group *) ((long unsigned int) n_group * 16))->h_group); + if (D.100642->alive) goto <L1>; else goto <L0>; <L0>:; if (discount_dead) goto <L8>; else goto <L1>; @@ -6385,72 +6402,70 @@ <L1>:; __n = (long unsigned int) n_group; __n = (long unsigned int) n_side; - D.86086 = sides.D.66353._M_impl._M_start; - if ((*(((D.86086 + (struct Side *) ((long unsigned int) this->my_side * 256))->scanned_groups.D.34444._M_impl._M_start + (struct vector<bool,std::allocator<bool> > *) (__n * 40))->D.67000._M_impl._M_start.D.26400._M_p + (_Bit_type *) ((__n >> 6) * 8)) & 1 << (int) ((unsigned int) __n & 63)) == 0) goto <L8>; else goto <L2>; + D.86107 = sides.D.66353._M_impl._M_start; + if ((*(((D.86107 + (struct Side *) ((long unsigned int) this->my_side * 256))->scanned_groups.D.34444._M_impl._M_start + (struct vector<bool,std::allocator<bool> > *) (__n * 40))->D.67000._M_impl._M_start.D.26400._M_p + (_Bit_type *) ((__n >> 6) * 8)) & 1 << (int) ((unsigned int) __n & 63)) == 0) goto <L8>; else goto <L2>; <L2>:; - D.100623 = operator-> (&((D.86086 + (struct Side *) (__n * 256))->groups.D.33422._M_impl._M_start + (struct Group *) (__n * 16))->h_group); - D.100627 = OBJ_TYPE_REF(*(D.100623->_vptr.Group_Base + 152B);D.100623->19) (D.100623); - if (D.100627 != 0) goto <L8>; else goto <L3>; + D.100677 = operator-> (&((D.86107 + (struct Side *) (__n * 256))->groups.D.33422._M_impl._M_start + (struct Group *) (__n * 16))->h_group); + D.100681 = OBJ_TYPE_REF(*(D.100677->_vptr.Group_Base + 152B);D.100677->19) (D.100677); + if (D.100681 != 0) goto <L8>; else goto <L3>; <L3>:; - if (this->my_side != n_side) goto <L160>; else goto <L4>; + if (this->my_side != n_side) goto <L163>; else goto <L4>; <L4>:; - if (this->my_group != n_group) goto <L160>; else goto <L5>; + if (this->my_group != n_group) goto <L163>; else goto <L5>; <L5>:; - if (discount_our) goto <L8>; else goto <L160>; + if (discount_our) goto <L8>; else goto <L163>; <L8>:; - D.86143 = this->l_iter._M_current; - if (D.86143 == this->l_end._M_current) goto <L36>; else goto <L103>; + D.86164 = this->l_iter._M_current; + if (D.86164 == this->l_end._M_current) goto <L36>; else goto <L103>; <L103>:; - D.86144 = *D.86143; - if (D.86144 == 157) goto <L36>; else goto <L104>; + temp.4648 = *D.86164; + if (temp.4648 == 157) goto <L36>; else goto <L104>; <L104>:; - if (D.86144 == 158) goto <L36>; else goto <L120>; + if (temp.4648 == 158) goto <L36>; else goto <L166>; -<L120>:; - this___l_iterthis__I___M_currentthis____.4616 = (const unsigned char *) ((long unsigned int) D.86143 + 1); +<L39>:; + D.86165 = *D.86148; + if (D.86165 == 157) goto <L36>; else goto <L40>; -Invalid sum of incoming frequencies 873, should be 0 <L40>:; - this___l_iterthis__I___M_currentthis____.4616 = (const unsigned char *) ((long unsigned int) this___l_iterthis__I___M_currentthis____.4616 + 1); - if (D.86144 == 157) goto <L162>; else goto <L40>; + if (D.86165 == 158) goto <L36>; else goto <L166>; -Invalid sum of incoming frequencies 0, should be 301 -<L162>:; - this->l_iter._M_current = this___l_iterthis__I___M_currentthis____.4616; - D.68741 = 0; - goto <bb 42> (<L174>); +<L166>:; + D.86148 = this->l_iter._M_current + 1B; + this->l_iter._M_current = D.86148; + if (this->l_end._M_current == D.86148) goto <L36>; else goto <L39>; <snip> James