File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -225,6 +225,17 @@ struct crn_packed_uint {
225225  }
226226
227227  inline  operator  unsigned  int () const  {
228+ #if  0 
229+     /* Compilers will expand the template with all conditions
230+     and generate the code for all conditions even if only one
231+     condition is usable per template variant.
232+ 
233+     Compilers like ICC will raise warnings at compile time,
234+     and code analysers like CodeQL will raise warnings when
235+     analysing the compiled binary.
236+ 
237+     See: https://github.com/DaemonEngine/crunch/issues/79 */
238+ 
228239    switch (N) {
229240      case 1:
230241        return m_buf[0];
@@ -235,6 +246,15 @@ struct crn_packed_uint {
235246      default:
236247        return (m_buf[0] << 24U) | (m_buf[1] << 16U) | (m_buf[2] << 8U) | (m_buf[3]);
237248    }
249+ #else 
250+     unsigned  int  val = 0U ;
251+ 
252+     for  (unsigned  int  i = 0U ; i < N; i++) {
253+       val |= m_buf[ i ] << ((N - (i + 1U )) * 8U );
254+     }
255+ 
256+     return  val;
257+ #endif 
238258  }
239259
240260  unsigned  char  m_buf[N];
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments