maartenbreddels commented on pull request #7656:
URL: https://github.com/apache/arrow/pull/7656#issuecomment-657009236


   I tried to isolate the issue, by creating gccbug.cc:
   ```c++
   #include <stdint.h>
   #include <algorithm>
   #include <string>
   
   class KernelContext;
   class Datum;
   class FunctionRegistry;
   
   struct DummyType {
     typedef int offset_type;
   };
   
   template <typename ArrowType, typename Derived>
   struct BinaryToBoolean {
     using offset_type = typename ArrowType::offset_type;
   
     static void Exec(KernelContext* ctx, Datum* out) {
       bool boolean_result = Derived::Predicate(ctx, nullptr, 10);
     }
   };
   
   template <typename ArrowType, typename Derived, bool allow_empty = false>
   struct CharacterPredicateAscii
       : BinaryToBoolean<ArrowType,
                         CharacterPredicateAscii<ArrowType, Derived, 
allow_empty>> {
     using offset_type = typename ArrowType::offset_type;
     static inline bool Predicate(KernelContext* ctx, const uint8_t* input,
                                  offset_type input_string_ncodeunits) {
       if (allow_empty && input_string_ncodeunits == 0) {
         return true;
       }
       bool any = false;
       // MB: A simple for loops seems 8% faster on gcc 9.3, running the 
IsAlphaNumericAscii
       // benchmark. I don't consider that worth it.
       bool all = std::all_of(input, input + input_string_ncodeunits,
                              [&any](uint8_t ascii_character) {
                                any |= 
Derived::PredicateCharacterAny(ascii_character);
                                return 
Derived::PredicateCharacterAll(ascii_character);
                              });
       return all & any;
     }
     static inline bool PredicateCharacterAny(uint8_t) {
       return true;  // default condition make sure there is at least 1 
charachter
     }
   };
   
   static inline bool IsLowerCaseCharacterAscii(uint8_t ascii_character) {
     return (ascii_character >= 'a') && (ascii_character <= 'z');
   }
   
   static inline bool IsUpperCaseCharacterAscii(uint8_t ascii_character) {
     return (ascii_character >= 'A') && (ascii_character <= 'Z');
   }
   
   static inline bool IsCasedCharacterAscii(uint8_t ascii_character) {
     return IsLowerCaseCharacterAscii(ascii_character) ||
            IsUpperCaseCharacterAscii(ascii_character);
   }
   
   static inline bool IsAlphaCharacterAscii(uint8_t ascii_character) {
     return IsCasedCharacterAscii(ascii_character);  // same
   }
   
   template <typename ArrowType>
   struct IsUpperAscii : CharacterPredicateAscii<ArrowType, 
IsUpperAscii<ArrowType>> {
     static inline bool PredicateCharacterAll(uint8_t ascii_character) {
       // Only for cased character it needs to be lower case
       return !IsCasedCharacterAscii(ascii_character) ||
              IsUpperCaseCharacterAscii(ascii_character);
     }
     static inline bool PredicateCharacterAny(uint8_t ascii_character) {
       return IsCasedCharacterAscii(ascii_character);  // at least 1 cased 
character
     }
   };
   template <template <typename> class Transformer>
   void AddUnaryString(std::string name, FunctionRegistry* registry) {
     //   auto func = std::make_shared<ScalarFunction>(name, Arity::Unary());
     auto exec_32 = Transformer<DummyType>::Exec;
     //   auto exec_64 = Transformer<LargeStringType>::Exec;
     //   DCHECK_OK(func->AddKernel({utf8()}, boolean(), exec_32));
     //   DCHECK_OK(func->AddKernel({large_utf8()}, boolean(), exec_64));
     //   DCHECK_OK(registry->AddFunction(std::move(func)));
   }
   
   int main() { AddUnaryString<IsUpperAscii>("ascii_isupper", nullptr); }
   ```
   
   And running:
   ```
   $ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp gcc:5 gcc -o 
gccbug cpp/src/arrow/compute/kernels/gccbug.cc -std=c++11
   $ docker run --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp gcc:8.3 gcc -o 
gccbug cpp/src/arrow/compute/kernels/gccbug.cc -std=c++11
   ```
   But both seem to compile, so I guess this is windows/gcc specific.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to