esbmc icon indicating copy to clipboard operation
esbmc copied to clipboard

[clang-cpp] `__builtin_memcpy` is not useable without also including `memcpy` header

Open intrigus-lgtm opened this issue 1 year ago • 0 comments

#include <cassert>

int main() {
  int src = 1;
  int dest = 2;
  __builtin_memcpy(&dest, &src, sizeof(int));
  assert(dest == 1);
}

fails with:

ESBMC version 7.6.1 64-bit x86_64 linux
Target: 64-bit little-endian x86_64-unknown-linux with esbmclibc
Parsing foo.cpp
foo.cpp:6:3: error: use of undeclared identifier 'memcpy'
  __builtin_memcpy(&dest, &src, sizeof(int));
  ^
<command line>:6:26: note: expanded from here
#define __builtin_memcpy memcpy
                         ^
ERROR: PARSING ERROR

This is because https://github.com/esbmc/esbmc/pull/572 simply defines __builtin_memcpy as memcpy which fails when memcpy is not included. Manually adding includes is not a solution, because this problem happens in a system header file. Related: https://github.com/esbmc/esbmc/issues/1669

intrigus-lgtm avatar Aug 14 '24 00:08 intrigus-lgtm