ivmai / bdwgc

The Boehm-Demers-Weiser conservative C/C++ Garbage Collector (bdwgc, also known as bdw-gc, boehm-gc, libgc)
https://www.hboehm.info/gc/
Other
2.96k stars 407 forks source link

Replacement function 'operator new' cannot be declared inline (Cygwin) #441

Open ivmai opened 2 years ago

ivmai commented 2 years ago

Source: master (2e1b8f205) Host: Cygwin (64-bit) Compiler: clang version 8.0.1 (tags/RELEASE_801/final) How to reproduce: Variant 1: clang++ -I include -c tests/cpp.cc Variant 2: CC=clang CXX=clang++ ./configure && make check Output:

In file included from tests/cpp.cc:25:
In file included from ./include/gc_cpp.h:2:
./include/gc/gc_cpp.h:289:5: warning: replacement function 'operator new[]' cannot be declared 'inline'
      [-Winline-new-delete]
    inline void* operator new[](size_t size)
    ^
./include/gc/gc_cpp.h:296:5: warning: replacement /bin/sh ./libtool  --tag=CC   --mode=link clang -Werror  -fexceptions -DGC_VISIBILITY_HIDDEN_SET -fvisibility=hidden -Wall -Wextra -Wpedantic -Wno-long-long -g -O2 -fno-strict-aliasing -O3 -D CPPCHECK   -o realloctest.exe tests/realloc.o  ./libgc.la
function 'operator delete[]' cannot be declared 'inline'
      [-Winline-new-delete]
    inline void operator delete[](void* obj) GC_NOEXCEPT
    ^
./include/gc/gc_cpp.h:302:3: warning: replacement function 'operator new' cannot be declared 'inline'
      [-Winline-new-delete]
  inline void* operator new(size_t size)
  ^
./include/gc/gc_cpp.h:309:3: warning: replacement function 'operator delete' cannot be declared 'inline'
      [-Winline-new-delete]
  inline void operator delete(void* obj) GC_NOEXCEPT
  ^

Note: not observed with gcc.

ivmai commented 2 years ago

Related issue: #229 Tip from there: -D GC_NOT_DLL is essential if compiling client C++ code and linking it static libs on Cygwin, otherwise clang produces warnings in gc_cpp.h.

ivmai commented 2 years ago

make check CFLAGS_EXTRA="-D GC_NOT_DLL" Gives other error:

libtool: link: clang++ -fexceptions -Wall -Wextra -Wpedantic -Wno-long-long -g -O2 -D GC_NOT_DLL -o .libs/cpptest.exe tests/cpp.o  ./.libs/libgccpp.dll.a /cygdrive/c/_/PersonalWS/git/bdwgc-m/.libs/libgc.dll.a -lsupc++ ./.libs/libgc.dll.a -L/usr/local/lib
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/libstdc++.dll.a(d006580.o):(.text+0x0): multiple definition of `__cxa_throw'; /usr/lib/gcc/x86_64-pc-cygwin/11/libsupc++.a(eh_throw.o):/usr/src/debug/gcc-11.2.0-1/libstdc++-v3/libsupc++/eh_throw.cc:77: first defined here
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/libstdc++.dll.a(d006561.o):(.text+0x0): multiple definition of `__cxa_begin_catch'; /usr/lib/gcc/x86_64-pc-cygwin/11/libsupc++.a(eh_catch.o):/usr/src/debug/gcc-11.2.0-1/libstdc++-v3/libsupc++/eh_catch.cc:41: first defined here
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/libstdc++.dll.a(d006558.o):(.text+0x0): multiple definition of `__cxa_allocate_exception'; /usr/lib/gcc/x86_64-pc-cygwin/11/libsupc++.a(eh_alloc.o):/usr/src/debug/gcc-11.2.0-1/libstdc++-v3/libsupc++/eh_alloc.cc:280: first defined here
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-cygwin/11/libstdc++.dll.a(d005443.o):(.text+0x0): multiple definition of `std::terminate()'; /usr/lib/gcc/x86_64-pc-cygwin/11/libsupc++.a(eh_terminate.o):/usr/src/debug/gcc-11.2.0-1/libstdc++-v3/libsupc++/eh_terminate.cc:57: first defined here
clang-8: error: linker command failed with exit code 1 (use -v to see invocation)
ivmai commented 2 years ago

Unclear who to fix it properly. The W/A could be just suppress the warning.