Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix undefined behaviour in OctNode #3561

Merged

Commits on Jan 16, 2020

  1. Fixes UB in pcl::poisson::OctNode

    Example
    
    ```cpp
    /// Must be compiled with -fsanitze=undefined
    #include <iostream>
    #include <stdio.h>
    
    long long _InterleaveBits( int p[3] )
    {
      long long key = 0;
      for( int i=0 ; i<32 ; i++ ) 
      {
        key |= ( ( p[0] & (1<<i) )<<(2*i) ) | ( ( p[1] & (1<<i) )<<(2*i+1) ) | ( ( p[2] & (1<<i) )<<(2*i+2) );
      }
      return key;
    }
    
    long long _FixedInterleaveBits( int _p[3] )
    {
      long long key = 0;
      long long p[3] = {_p[0],_p[1],_p[2]};
      for( int i=0 ; i<31 ; i++ ) 
      {
        key |= ( ( p[0] & (1ull<<i) )<<(2*i) ) | ( ( p[1] & (1ull<<i) )<<(2*i+1) ) | ( ( p[2] & (1ull<<i) )<<(2*i+2) );
      }
      return key;
    }
    
    int main() {
      int p[3] = {0,255,128};
      std::cout << _InterleaveBits(p) << std::endl;
      std::cout << _FixedInterleaveBits(p) << std::endl;
    }
    ```
    RLThomaz committed Jan 16, 2020
    Configuration menu
    Copy the full SHA
    38cccab View commit details
    Browse the repository at this point in the history