Skip to content

warning: macro expansion producing 'defined' has undefined behavior #2141

@ezyang

Description

@ezyang

In torch/csrc/generic/TensorMethods.cwrap we define a number of macros which are subsequently used in if statements:

#ifndef THC_GENERIC_FILE
#define IS_CUDA false
#define CUDA_FLOAT false
#else
#define IS_CUDA true
#define CUDA_BYTE defined(THC_REAL_IS_BYTE)
#define CUDA_CHAR defined(THC_REAL_IS_CHAR)
#define CUDA_SHORT defined(THC_REAL_IS_SHORT)
#define CUDA_INT defined(THC_REAL_IS_INT)
#define CUDA_LONG defined(THC_REAL_IS_LONG)
#define CUDA_FLOAT defined(THC_REAL_IS_FLOAT)
#define CUDA_DOUBLE defined(THC_REAL_IS_DOUBLE)
#define CUDA_HALF defined(THC_REAL_IS_HALF)
#endif

This is undefined. On clang 3.4.2, these warnings don't seem to actually get printed out (777 warnings generated.) but on clang 4.0.0 they seem to always get emitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions