title: (C++) Getting error "Illegal instruction (core dumped)" upon bitwise OR operation
body: <p>So, I'm still learning about bitwise operations and can't figure out why this error is happening. I've googled it and it appears that this error can happen when messing with the stack, or, in some cases, it has to do with CPU architecture. I've tried compiling with different flags that were supposed to help but I can't get it to work.</p>
  
  <p>Here's the the code quickly:</p>
  
  <pre><code>int corners = 0;
  for (int i = 0; i &lt; 8; i++)
  {
      const ivec3 cornerPos = leaf-&gt;min + CHILD_MIN_OFFSETS[i];
      const float density = Density_Func(vec3(cornerPos));
      const int material = density &lt; 0.f ? MATERIAL_SOLID : MATERIAL_AIR;
      corners |= (material &lt;&lt; i);
  }
  </code></pre>
  
  <p>And the error "Illegal instruction (core dumped)" is happening at the line</p>
  
  <p><code>corners |= (material &lt;&lt; i);</code></p>
  
  <p>Here's the output from the debugger:</p>
  
  <pre><code>Signal received: SIGILL (Illegal instruction) For program, pid 26,118
  </code></pre>
  
  <p>I'm going to give the output of this loop (it never makes it past the first loop).
  Here's the code for the couts:</p>
  
  <pre><code>int corners = 0;
      std::cout&lt;&lt;"corners(outside loop): "&lt;&lt;corners&lt;&lt;std::endl;
  
  for (int i = 0; i &lt; 8; i++)
  {
      const ivec3 cornerPos = leaf-&gt;min + CHILD_MIN_OFFSETS[i];
              std::cout&lt;&lt;"cornerPos.x: "&lt;&lt;cornerPos.x&lt;&lt;std::endl;
              std::cout&lt;&lt;"cornerPos.y: "&lt;&lt;cornerPos.y&lt;&lt;std::endl;
              std::cout&lt;&lt;"cornerPos.z: "&lt;&lt;cornerPos.z&lt;&lt;std::endl;
  
      const float density = Density_Func(vec3(cornerPos));
              std::cout&lt;&lt;"density: "&lt;&lt;density&lt;&lt;std::endl;
  
      const int material = density &lt; 0.f ? MATERIAL_SOLID : MATERIAL_AIR;
              std::cout&lt;&lt;"material: "&lt;&lt;material&lt;&lt;std::endl;
  
              std::cout&lt;&lt;"MATERIAL_SOLID: "&lt;&lt;MATERIAL_SOLID&lt;&lt;std::endl;
              std::cout&lt;&lt;"MATERIAL_AIR: "&lt;&lt;MATERIAL_AIR&lt;&lt;std::endl;
              std::cout&lt;&lt;"i: "&lt;&lt;i&lt;&lt;std::endl;
  
      corners |= (material &lt;&lt; i);
              std::cout&lt;&lt;"corners(inside loop): "&lt;&lt;corners&lt;&lt;std::endl;
  }
  </code></pre>
  
  <p>and here's the output:</p>
  
  <pre><code>[corners(outside loop): 0] [cornerPos.x: -32] [cornerPos.y: -32] [cornerPos.z: -32] [density: -30] [material: 1] [MATERIAL_SOLID: 1] [MATERIAL_AIR: 0] [i: 0]
  </code></pre>
  
  <p>I would greatly appreciate any insight someone can give me about why this is happening, and if there is a clear reason, how to go about fixing the problem.</p>
  
  <p>Thank you!</p>