Repository: pytorch
Issue: Failed to compile: null in call to `__builtin_memmove(__result, __first, sizeof(_Tp) * _Num);` Debian 12, ppc64le, gcc 12.2
Labels: module: build,triaged

### 🐛 Describe the bug

Trying to compile [PyTorch 2.1](https://github.com/pytorch/pytorch/releases/tag/v2.1.0) on
* Debian 12.2
* Kernel: 6.1.0-13
* gcc: 12.2.0
* Architecture: ppc64le

It fails when trying to compile, when when I disabled building of the tests as instructed in `setup.py`.

```
❯ USE_CUDA=0 USE_ROCM=0 USE_OPENMP=1 BUILD_TEST=0 python setup.py develop
fatal: not a git repository (or any of the parent directories): .git
Building wheel torch-2.1.0a0+gitUnknown
-- Building version 2.1.0a0+gitUnknown
cmake --build . --target install --config Release
[16/18] Building CXX object test_api/CMakeFiles/test_api.dir/dataloader.cpp.o
FAILED: test_api/CMakeFiles/test_api.dir/dataloader.cpp.o 
/usr/bin/ccache /usr/bin/c++ -DHAVE_MALLOC_USABLE_SIZE=1 -DHAVE_MMAP=1 -DHAVE_SHM_OPEN=1 -DHAVE_SHM_UNLINK=1 -DMINIZ_DISABLE_ZIP_READER_CRC32_CHECKS -DONNXIFI_ENABLE_EXT=1 -DONNX_ML=1 -DONNX_NAMESPACE=onnx_torch -DUSE_C10D_GLOO -DUSE_C10D_MPI -DUSE_DISTRIBUTED -DUSE_EXTERNAL_MZCRC -DUSE_RPC -DUSE_TENSORPIPE -D_FILE_OFFSET_BITS=64 -I/home/rjzak/Downloads/pytorch-v2.1.0/build/aten/src -I/home/rjzak/Downloads/pytorch-v2.1.0/aten/src -I/home/rjzak/Downloads/pytorch-v2.1.0/build -I/home/rjzak/Downloads/pytorch-v2.1.0 -I/home/rjzak/Downloads/pytorch-v2.1.0/cmake/../third_party/benchmark/include -I/home/rjzak/Downloads/pytorch-v2.1.0/third_party/onnx -I/home/rjzak/Downloads/pytorch-v2.1.0/build/third_party/onnx -I/home/rjzak/Downloads/pytorch-v2.1.0/third_party/foxi -I/home/rjzak/Downloads/pytorch-v2.1.0/build/third_party/foxi -I/home/rjzak/Downloads/pytorch-v2.1.0/build/caffe2/../aten/src -I/home/rjzak/Downloads/pytorch-v2.1.0/torch/csrc/api -I/home/rjzak/Downloads/pytorch-v2.1.0/torch/csrc/api/include -I/home/rjzak/Downloads/pytorch-v2.1.0/c10/.. -isystem /home/rjzak/Downloads/pytorch-v2.1.0/build/third_party/gloo -isystem /home/rjzak/Downloads/pytorch-v2.1.0/cmake/../third_party/gloo -isystem /home/rjzak/Downloads/pytorch-v2.1.0/cmake/../third_party/tensorpipe/third_party/libuv/include -isystem /home/rjzak/Downloads/pytorch-v2.1.0/cmake/../third_party/googletest/googlemock/include -isystem /home/rjzak/Downloads/pytorch-v2.1.0/cmake/../third_party/googletest/googletest/include -isystem /home/rjzak/Downloads/pytorch-v2.1.0/third_party/protobuf/src -isystem /home/rjzak/Downloads/pytorch-v2.1.0/cmake/../third_party/eigen -isystem /usr/lib/powerpc64le-linux-gnu/openmpi/include -isystem /usr/lib/powerpc64le-linux-gnu/openmpi/include/openmpi -isystem /home/rjzak/Downloads/pytorch-v2.1.0/third_party/googletest/googletest/include -isystem /home/rjzak/Downloads/pytorch-v2.1.0/third_party/googletest/googletest -D_GLIBCXX_USE_CXX11_ABI=1 -fvisibility-inlines-hidden -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=range-loop-construct -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=old-style-cast -Wno-invalid-partial-specialization -Wno-unused-private-field -Wno-aligned-allocation-unavailable -Wno-missing-braces -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow -O3 -DNDEBUG -DNDEBUG -fPIE -DBLAS_HAS_SBGEMM -DTORCH_USE_LIBUV -DCAFFE2_USE_GLOO -DTH_HAVE_THREAD -Wno-unused-variable -Wno-missing-braces -Wno-maybe-uninitialized -Wno-unused-but-set-parameter -std=gnu++17 -MD -MT test_api/CMakeFiles/test_api.dir/dataloader.cpp.o -MF test_api/CMakeFiles/test_api.dir/dataloader.cpp.o.d -o test_api/CMakeFiles/test_api.dir/dataloader.cpp.o -c /home/rjzak/Downloads/pytorch-v2.1.0/test/cpp/api/dataloader.cpp
In file included from /usr/include/c++/12/memory:63,
                 from /home/rjzak/Downloads/pytorch-v2.1.0/third_party/googletest/googletest/include/gtest/gtest.h:57,
                 from /home/rjzak/Downloads/pytorch-v2.1.0/test/cpp/api/dataloader.cpp:1:
In static member function ‘static _Tp* std::__copy_move<_IsMove, true, std::random_access_iterator_tag>::__copy_m(const _Tp*, const _Tp*, _Tp*) [with _Tp = long unsigned int; bool _IsMove = false]’,
    inlined from ‘_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = const long unsigned int*; _OI = long unsigned int*]’ at /usr/include/c++/12/bits/stl_algobase.h:495:30,
    inlined from ‘_OI std::__copy_move_a1(_II, _II, _OI) [with bool _IsMove = false; _II = const long unsigned int*; _OI = long unsigned int*]’ at /usr/include/c++/12/bits/stl_algobase.h:522:42,
    inlined from ‘_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = __gnu_cxx::__normal_iterator<const long unsigned int*, vector<long unsigned int> >; _OI = __gnu_cxx::__normal_iterator<long unsigned int*, vector<long unsigned int> >]’ at /usr/include/c++/12/bits/stl_algobase.h:529:31,
    inlined from ‘_OI std::copy(_II, _II, _OI) [with _II = __gnu_cxx::__normal_iterator<const long unsigned int*, vector<long unsigned int> >; _OI = __gnu_cxx::__normal_iterator<long unsigned int*, vector<long unsigned int> >]’ at /usr/include/c++/12/bits/stl_algobase.h:620:7,
    inlined from ‘std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long unsigned int; _Alloc = std::allocator<long unsigned int>]’ at /usr/include/c++/12/bits/vector.tcc:244:21:
/usr/include/c++/12/bits/stl_algobase.h:431:30: error: argument 1 null where non-null expected [-Werror=nonnull]
  431 |             __builtin_memmove(__result, __first, sizeof(_Tp) * _Num);
      |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

### Versions

```
❯ python collect_env.py 
Collecting environment information...
PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: N/A

OS: Debian GNU/Linux 12 (bookworm) (ppc64le)
GCC version: (Debian 12.2.0-14) 12.2.0
Clang version: 14.0.6
CMake version: version 3.25.1
Libc version: glibc-2.36

Python version: 3.11.4 (main, Jul  5 2023, 13:37:27) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-6.1.0-13-powerpc64le-ppc64le-with-glibc2.36
Is CUDA available: N/A
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: N/A

CPU:
Architecture:                       ppc64le
Byte Order:                         Little Endian
CPU(s):                             64
On-line CPU(s) list:                0-63
Model name:                         POWER9, altivec supported
Model:                              2.3 (pvr 004e 1203)
Thread(s) per core:                 4
Core(s) per socket:                 8
Socket(s):                          2
Frequency boost:                    enabled
CPU(s) scaling MHz:                 62%
CPU max MHz:                        3800.0000
CPU min MHz:                        2166.0000
L1d cache:                          512 KiB (16 instances)
L1i cache:                          512 KiB (16 instances)
L2 cache:                           8 MiB (16 instances)
L3 cache:                           160 MiB (16 instances)
NUMA node(s):                       2
NUMA node0 CPU(s):                  0-31
NUMA node8 CPU(s):                  32-63
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Mitigation; RFI Flush, L1D private per thread
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Mitigation; RFI Flush, L1D private per thread
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Kernel entry/exit barrier (eieio)
Vulnerability Spectre v1:           Mitigation; __user pointer sanitization, ori31 speculation barrier enabled
Vulnerability Spectre v2:           Mitigation; Software count cache flush (hardware accelerated), Software link stack flush
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] numpy==1.24.3
[conda] numpy                     1.24.3          py311h148a09e_0  
[conda] numpy-base                1.24.3          py311h06b82f6_0  
```

cc @malfet @seemethere