Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors with Clang in C++11 mode #330

Closed
huhlig opened this issue Apr 18, 2013 · 9 comments
Closed

Errors with Clang in C++11 mode #330

huhlig opened this issue Apr 18, 2013 · 9 comments

Comments

@huhlig
Copy link
Contributor

huhlig commented Apr 18, 2013

/root/llvm/src/ldc/dmd2/func.c:540:18: error: case value evaluates to -2, which cannot be narrowed to type 'size_t' (aka 'unsigned long') [-Wc++11-narrowing]
case -2: // can't determine because of fwd refs
^
/root/llvm/src/ldc/dmd2/func.c:503:18: error: case value evaluates to -1, which cannot be narrowed to type 'size_t' (aka 'unsigned long') [-Wc++11-narrowing]
case -1:
^
/root/llvm/src/ldc/dmd2/func.c:632:22: error: case value evaluates to -2, which cannot be narrowed to type 'size_t' (aka 'unsigned long') [-Wc++11-narrowing]
case -2:
^
/root/llvm/src/ldc/dmd2/func.c:629:22: error: case value evaluates to -1, which cannot be narrowed to type 'size_t' (aka 'unsigned long') [-Wc++11-narrowing]
case -1:
^
4 errors generated.
make[2]: *** [CMakeFiles/LDCShared.dir/dmd2/func.c.o] Error 1

@huhlig
Copy link
Contributor Author

huhlig commented Apr 18, 2013

[ 0%] Building CXX object CMakeFiles/LDCShared.dir/dmd2/func.c.o
/usr/local/bin/clang++ -DDMDV2 -DIN_LLVM -DOPAQUE_VTBLS -DLDC_INSTALL_PREFIX="/usr/local" -DLDC_LLVM_VER=303 -DLDC_LLVM_VERSION_STRING="3.3svn" -DPOSIX -DUSE_METADATA -D__LITTLE_ENDIAN__ -DLLVM_INTRINSIC_TD_PATH="/usr/local/include" -DHAVE_SC_ARG_MAX -I/root/llvm/src/ldc/. -I/root/llvm/src/ldc/dmd2 -I/root/llvm/src/ldc/dmd2/root -I/root/llvm/build/ldc/dmd2 -I/root/llvm/src/ldc -I/usr/local/include -I/usr/local/include -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -O3 -fomit-frame-pointer -std=c++11 -fvisibility-inlines-hidden -fno-exceptions -fno-rtti -fPIC -Woverloaded-virtual -Wcast-qual -fexceptions -w -o CMakeFiles/LDCShared.dir/dmd2/func.c.o -c /root/llvm/src/ldc/dmd2/func.c
/root/llvm/src/ldc/dmd2/func.c:540:18: error: case value evaluates to -2, which cannot be narrowed to type 'size_t' (aka 'unsigned long') [-Wc++11-narrowing]
case -2: // can't determine because of fwd refs
^
/root/llvm/src/ldc/dmd2/func.c:503:18: error: case value evaluates to -1, which cannot be narrowed to type 'size_t' (aka 'unsigned long') [-Wc++11-narrowing]
case -1:
^
/root/llvm/src/ldc/dmd2/func.c:632:22: error: case value evaluates to -2, which cannot be narrowed to type 'size_t' (aka 'unsigned long') [-Wc++11-narrowing]
case -2:
^
/root/llvm/src/ldc/dmd2/func.c:629:22: error: case value evaluates to -1, which cannot be narrowed to type 'size_t' (aka 'unsigned long') [-Wc++11-narrowing]
case -1:
^
4 errors generated.
make[2]: *** [CMakeFiles/LDCShared.dir/dmd2/func.c.o] Error 1

@redstar
Copy link
Member

redstar commented Apr 19, 2013

I never tried it but I can imagine that the DMD source is not C++11 compatible. Did you try to compile LDC without -Wc++11-narrowing? In general, LDC compiles with clang.

@huhlig
Copy link
Contributor Author

huhlig commented Apr 19, 2013

I'm only using the default clang settings. Not adding anything special.

@huhlig
Copy link
Contributor Author

huhlig commented Apr 19, 2013

Build Script below

rm -Rf ~/llvm
mkdir -p ~/llvm/build/llvm ~/llvm/build/ldc ~/llvm/build/lldb
svn co http://llvm.org/svn/llvm-project/llvm/trunk ~/llvm/src/llvm
svn co http://llvm.org/svn/llvm-project/lldb/trunk ~/llvm/src/llvm/tools/lldb
svn co http://llvm.org/svn/llvm-project/cfe/trunk ~/llvm/src/llvm/tools/clang
svn co http://llvm.org/svn/llvm-project/clang-tools-extra/trunk ~/llvm/src/llvm/tools/clang/tools/extra
svn co http://llvm.org/svn/llvm-project/compiler-rt/trunk ~/llvm/src/llvm/projects/compiler-rt
git clone --recursive http://github.com/ldc-developers/ldc.git ~/llvm/src/ldc
(cd ~/llvm/build/llvm && ~/llvm/src/llvm/configure --enable-optimized --enable-doxygen --enable-cxx11 && make && make install)
export CC=clang
export CXX=clang++
(cd ~/llvm/build/ldc && cmake ~/llvm/src/ldc && make && make install)

@huhlig
Copy link
Contributor Author

huhlig commented Apr 19, 2013

Side note: "case value evaluates to -2, which cannot be narrowed to type 'size_t' " Why is the input an unsigned value and the case is negative... that seems very naughty.

@dnadlinger
Copy link
Member

Ah, so the C++11 option is leaking in from the LLVM CFLAGS? I think the best thing to do would just be to fix the DMD source.

Regarding -1/-2, DMD uses such "special" unsigned values (i.e. size_t.max, size_t.max - 1, …) quite liberally.

@dnadlinger
Copy link
Member

@huhlig: To test my hypothesis, could you please run llvm-config --cxxflags?

@dnadlinger
Copy link
Member

This is an upstream problem, the DMD source does not compile with Clang and C++11 enabled yet.

AlexeyProkhin pushed a commit to AlexeyProkhin/ldc that referenced this issue Jun 18, 2013
@redstar
Copy link
Member

redstar commented Jan 3, 2014

I am closing this issue because LDC can now be compiled with -std=c++11.

@redstar redstar closed this as completed Jan 3, 2014
redstar pushed a commit that referenced this issue Sep 27, 2014
Fill out core.sys.posix.sys.select for Solaris.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants