Nvcc giving error due to the use of "and", "or" keywords

I am trying to build someone else’s PyTorch cpp/CUDA extension library on Windows. Their code uses “and”, “or” keywords in place of the usual “&&”, “||”. When I try to build that library on Windows, nvcc gives errors wherever those keywords are used.

Is there a command line option I can pass to nvcc to accept those keywords? I did go through the list of options available and did not see anything that is explicitly documented as handling those.

Thanks!
P.S. Though I myself always stick to the ‘&&’, ‘||’ syntax, I learned that the C/C++ standard does allow the use of “and”, “or” keywords. For “cl” compiler, passing the “/permissive-” flag makes it accept those keywords. I am wondering whether there is something equivalent for nvcc.

I am unable to reproduce this issue. I tried with CUDA 9.2 and MVS2010 (support has been deprecated, but still seems to work OK).

#include <cstdio>
#include <ciso646>

void __global__ kernel (int n)
{
    if (n > 0 and n < 5) {
        printf ("GPU: here n=%d\n", n);
    }
}

int n = 4;
int main()
{
   if (n > 0 and n < 5) {
       printf ("CPU: here n=%d\n", n);
   }
   kernel<<<1,1>>>(n);
   cudaDeviceSynchronize();
   return EXIT_SUCCESS;
}

When I run the above code on a Windows 7 machine with a Quadro K420, I get the expected output:

CPU: here n=4
GPU: here n=4

Did you forget to include the relevant header file by any chance?

What command line options are you passing to nvcc?
P.S. I am running on a Windows 10 machine with Visual Studio 2019.

nvcc -o text_logic_ops.exe text_logic_ops.cu

As far as I am aware, these alternative operators are implemented by simple textual substitution by the standard header file ciso646, and have been working for a long time.

Check whether ciso646 is actually included in the code. If the programmer forgot this, the code may still work on some platforms because that header file happens to be included by other header files on those platforms.

[Later:]

The reference site https://en.cppreference.com/w/cpp/language/operator_alternative tells me that the inclusion of ciso646 should not be required in C++, as the alternative keywords are part of the C++ standard. In the C++11 standard (the most recent one in my possession) the alternative tokens are specified in section 2.6.

In light of this it seems like a bug should be filed with NVIDIA.