Segmentation fault when passing to a function "map containers" by reference
<p>Greetings everyone,</p>

<p>I have a map of maps </p>

<pre><code>typedef  boost::unordered_map &lt;flow_t, individual_flow_table, fhash, fequal_to&gt;   flow_redundancy_map_t; 
</code></pre>

<p>flow_t is a structure of 5 unsigned integers, fhash and fequal_to are done using the std way as prescribed in boost library.</p>

<pre><code>   struct individual_flow_table{

redundancy_t flow_redundancy; 
     //flow_redundancy is again a map -please see typedef below

unsigned long long redundant_bytes;

unsigned long long num_accesses;

unsigned long long flow_size;

 };

typedef map &lt;unsigned long long , pkt_data&gt; redundancy_t; 
  //pkt_data is a structure of 3 unsigned long long

 flow_redundancy_map_t sorted_flows;
</code></pre>

<p>I insert into sorted_flows "individual_flow_tables" by initializing the longs and then clearing the "flow_redundancy" map.</p>

<p>Later I access the map "sorted_flows" using "flow_t" as the key and I get the "flow_redundancy" map as the value (Code below) </p>

<pre><code>          local_flow_redundancy = it-&gt;second.redundant_bytes;

      local_num_accesses = it-&gt;second.num_accesses;

       winnow(it-&gt;second.flow_redundancy);

       it-&gt;second.redundant_bytes = local_flow_redundancy ;

       it-&gt;second.num_accesses = local_num_accesses ;

           /* More code */

          void winnow(redundancy_t &amp; red_table)

          {         unsigned long long some_key; 
                    pkt_data  some_value;
                  //more code for computation of some_key 

                  redundancy_t::iterator it = red_table.find(some_key);

                  if(it!=red_table.end())

                  /*Some updating of the red_table*/
                  else

                     red_table.insert(make_pair(some_key, some_value));

            }                  
</code></pre>

<p>I get a segmentation fault on the insert to "red_table". 
   I run with valgrind it gives me 
   "Conditional jump or move depends on uninitialised value(s)" at the insert line of the code. </p>

<p>Alternatively, instead of passing by reference "red_table" in function "winnow", I indexed again (using the same flow_t) into the "sorted_flow" map and got the "red_table" in place. It worked fine. </p>

<p>I suppose it has to do something with passing by reference. 
I am a bit green on C++, though reasonably proficient in C. 
Any pointers will be very helpful. I can also provide more clarification if needed.</p>

<p>Thank You
Govind</p>
