Repository: opencv
Issue: error: calling a __host__ function("__builtin_clzl") from a __device__ function("std::__lg") is not allowed
Labels: bug,priority: low,category: build/install

This happens when compiling with cuda in debug mode

```
INFO: From Compiling external/opencv_repo3/modules/nonfree/src/surf.cpp:
external/gcc_4_8/usr/include/c++/4.8/bits/stl_algobase.h(989): error: calling a __host__ function("__builtin_clzl") from a __device__ function("std::__lg") is not allowed
```

##### System information (version)
- OpenCV => 2.4.13.2
- Operating System / Platform => ubuntu 16.04
- Compiler => bazel

##### Detailed description

```
third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -nostdinc -isystem external/gcc_4_8/usr/include -isystem external/gcc_4_8/usr/include/x86_64-linux-gnu -isystem external/gcc_4_8/usr/lib/gcc/x86_64-linux-gnu/4.8/include -isystem external/gcc_4_8/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -DROS_ASSERT_ENABLED -Werror -Wextra -Wno-unused-parameter -g '-std=c++11' -isystem external/gcc_4_8/usr/include/c++/4.8 -isystem external/gcc_4_8/usr/include/c++/4.8/backward -isystem external/gcc_4_8/usr/include/x86_64-linux-gnu/c++/4.8 -Wnon-virtual-dtor -MD -MF bazel-out/local_linux-dbgcuda/bin/external/opencv_repo3/_objs/nonfree/external/opencv_repo3/modules/nonfree/src/surf.pic.d '-frandom-seed=bazel-out/local_linux-dbgcuda/bin/external/opencv_repo3/_objs/nonfree/external/opencv_repo3/modules/nonfree/src/surf.pic.o' -fPIC -DHAVE_AV_CONFIG_H -DZLIB_CONST '-D_FILE_OFFSET_BITS=64' -D_ISOC99_SOURCE -D_LARGEFILE_SOURCE '-D_POSIX_C_SOURCE=200112' '-D_XOPEN_SOURCE=600' -DPIC -iquote external/opencv_repo3 -iquote bazel-out/local_linux-dbgcuda/genfiles/external/opencv_repo3 -iquote external/zlib_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/zlib_repo -iquote external/bazel_tools -iquote bazel-out/local_linux-dbgcuda/genfiles/external/bazel_tools -iquote external/tbb_repo2 -iquote bazel-out/local_linux-dbgcuda/genfiles/external/tbb_repo2 -iquote . -iquote bazel-out/local_linux-dbgcuda/genfiles -iquote external/cuda_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/cuda_repo -iquote external/libv4l_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/libv4l_repo -iquote external/png_repo2 -iquote bazel-out/local_linux-dbgcuda/genfiles/external/png_repo2 -iquote external/jpeg_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/jpeg_repo -iquote external/bz2_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/bz2_repo -iquote external/liblzma_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/liblzma_repo -iquote external/libsctp_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/libsctp_repo -iquote external/valgrind_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/valgrind_repo -iquote external/x264_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/x264_repo -iquote external/dc1394_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/dc1394_repo -iquote external/libtiff_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/libtiff_repo -iquote external/libjbig_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/libjbig_repo -iquote external/libgtk_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/libgtk_repo -iquote external/libglib_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/libglib_repo -iquote external/x11_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/x11_repo -iquote external/libcairo_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/libcairo_repo -iquote external/libfontconfig_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/libfontconfig_repo -iquote external/libexpat1_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/libexpat1_repo -iquote external/libfreetype_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/libfreetype_repo -iquote external/libpango_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/libpango_repo -iquote external/libharfbuzz_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/libharfbuzz_repo -iquote external/libxml_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/libxml_repo -iquote external/libatk_repo -iquote bazel-out/local_linux-dbgcuda/genfiles/external/libatk_repo -isystem external/opencv_repo3 -isystem bazel-out/local_linux-dbgcuda/genfiles/external/opencv_repo3 -isystem external/opencv_repo3/modules/nonfree/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/opencv_repo3/modules/nonfree/include -isystem external/opencv_repo3/modules/imgproc/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/opencv_repo3/modules/imgproc/include -isystem external/opencv_repo3/modules/core/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/opencv_repo3/modules/core/include -isystem external/opencv_repo3/modules/dynamicuda/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/opencv_repo3/modules/dynamicuda/include -isystem external/opencv_repo3/modules/gpu/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/opencv_repo3/modules/gpu/include -isystem external/zlib_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/zlib_repo/usr/include -isystem external/zlib_repo/usr/include/x86_64-linux-gnu -isystem bazel-out/local_linux-dbgcuda/genfiles/external/zlib_repo/usr/include/x86_64-linux-gnu -isystem external/bazel_tools/tools/cpp/gcc3 -isystem external/tbb_repo2/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/tbb_repo2/usr/include -isystem external/opencv_repo3/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/opencv_repo3/include -isystem external/cuda_repo -isystem bazel-out/local_linux-dbgcuda/genfiles/external/cuda_repo -isystem external/cuda_repo/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/cuda_repo/include -isystem external/opencv_repo3/modules/features2d/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/opencv_repo3/modules/features2d/include -isystem external/opencv_repo3/modules/flann/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/opencv_repo3/modules/flann/include -isystem external/opencv_repo3/modules/calib3d/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/opencv_repo3/modules/calib3d/include -isystem external/opencv_repo3/modules/objdetect/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/opencv_repo3/modules/objdetect/include -isystem external/opencv_repo3/modules/highgui/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/opencv_repo3/modules/highgui/include -isystem external/libv4l_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libv4l_repo/usr/include -isystem external/png_repo2/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/png_repo2/usr/include -isystem external/jpeg_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/jpeg_repo/usr/include -isystem external/jpeg_repo/usr/include/x86_64-linux-gnu -isystem bazel-out/local_linux-dbgcuda/genfiles/external/jpeg_repo/usr/include/x86_64-linux-gnu -isystem third_party/ffmpeg -isystem bazel-out/local_linux-dbgcuda/genfiles/third_party/ffmpeg -isystem third_party/ffmpeg/third_party/ffmpeg -isystem bazel-out/local_linux-dbgcuda/genfiles/third_party/ffmpeg/third_party/ffmpeg -isystem external/bz2_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/bz2_repo/usr/include -isystem external/liblzma_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/liblzma_repo/usr/include -isystem external/libsctp_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libsctp_repo/usr/include -isystem external/valgrind_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/valgrind_repo/usr/include -isystem external/x264_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/x264_repo/usr/include -isystem external/dc1394_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/dc1394_repo/usr/include -isystem external/libtiff_repo/usr/include/x86_64-linux-gnu -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libtiff_repo/usr/include/x86_64-linux-gnu -isystem external/libjbig_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libjbig_repo/usr/include -isystem external/libgtk_repo/usr/include/gtk-2.0 -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libgtk_repo/usr/include/gtk-2.0 -isystem external/libgtk_repo/usr/lib/x86_64-linux-gnu/gtk-2.0/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libgtk_repo/usr/lib/x86_64-linux-gnu/gtk-2.0/include -isystem external/libgtk_repo/usr/include/gdk-pixbuf-2.0 -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libgtk_repo/usr/include/gdk-pixbuf-2.0 -isystem external/libglib_repo/usr/include/glib-2.0 -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libglib_repo/usr/include/glib-2.0 -isystem external/libglib_repo/usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libglib_repo/usr/lib/x86_64-linux-gnu/glib-2.0/include -isystem external/x11_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/x11_repo/usr/include -isystem external/libcairo_repo/usr/include/cairo -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libcairo_repo/usr/include/cairo -isystem external/libfontconfig_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libfontconfig_repo/usr/include -isystem external/libexpat1_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libexpat1_repo/usr/include -isystem external/libfreetype_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libfreetype_repo/usr/include -isystem external/libpango_repo/usr/include/pango-1.0 -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libpango_repo/usr/include/pango-1.0 -isystem external/libharfbuzz_repo/usr/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libharfbuzz_repo/usr/include -isystem external/libxml_repo/usr/include/libxml2 -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libxml_repo/usr/include/libxml2 -isystem external/libatk_repo/usr/include/atk-1.0 -isystem bazel-out/local_linux-dbgcuda/genfiles/external/libatk_repo/usr/include/atk-1.0 -isystem external/opencv_repo3/modules/video/include -isystem bazel-out/local_linux-dbgcuda/genfiles/external/opencv_repo3/modules/video/include -x cuda '-DGOOGLE_CUDA=1' -DCUDA_FOUND -DUSE_CUDA '-nvcc_options=expt-relaxed-constexpr' -no-canonical-prefixes -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/opencv_repo3/modules/nonfree/src/surf.cpp -o bazel-out/local_linux-dbgcuda/bin/external/opencv_repo3/_objs/nonfree/external/opencv_repo3/modules/nonfree/src/surf.pic.o)
INFO: From Compiling external/opencv_repo3/modules/nonfree/src/surf.cpp:
external/gcc_4_8/usr/include/c++/4.8/bits/stl_algobase.h(989): error: calling a __host__ function("__builtin_clzl") from a __device__ function("std::__lg") is not allowed
```