-
Notifications
You must be signed in to change notification settings - Fork 854
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
Fix for most Xcode/clang warnings on OSX #5
Conversation
- member initializing order in some constructors - missing default branches in switch-case - uninitialized variable if switch-case default (uncritical because program would exit) - && and || brace warnings in if()
Fix for most Xcode/clang warnings on OSX
This warning still exists when compiling on Linux as well:
This is not just a warning but a potential bug. The underlying type of an unscoped enum is an implementation-defined integral type capable of representing all values of the enum. Considering that spv::Builtin only represent a limit number of enum values the underlying type could be 16-bit or even 8-bit in which case the comparison to 0xFFFFFFFF (spv::BadValue) will always be false. |
Sync code from KhronosGroup/glslang master
UBSAN rightly complains on `push_front`: glslang/MachineIndependent/localintermediate.h:100:8: runtime error: load of value 160, which is not a valid value for type 'bool' #0 in glslang::TCall::TCall(glslang::TCall&&) glslang/MachineIndependent/localintermediate.h:100 KhronosGroup#1 in void __gnu_cxx::new_allocator<std::_List_node<glslang::TCall> >::construct<glslang::TCall, glslang::TCall>(glslang::TCall*, glslang::TCall&&) /usr/include/c++/10/ext/new_allocator.h:150 KhronosGroup#2 in void std::allocator_traits<std::allocator<std::_List_node<glslang::TCall> > >::construct<glslang::TCall, glslang::TCall>(std::allocator<std::_List_node<glslang::TCall> >&, glslang::TCall*, glslang::TCall&&) /usr/include/c++/10/bits/alloc_traits.h:512 KhronosGroup#3 in std::_List_node<glslang::TCall>* std::__cxx11::list<glslang::TCall, std::allocator<glslang::TCall> >::_M_create_node<glslang::TCall>(glslang::TCall&&) (...) KhronosGroup#4 in void std::__cxx11::list<glslang::TCall, std::allocator<glslang::TCall> >::_M_insert<glslang::TCall>(std::_List_iterator<glslang::TCall>, glslang::TCall&&) /usr/include/c++/10/bits/stl_list.h:1911 KhronosGroup#5 in std::__cxx11::list<glslang::TCall, std::allocator<glslang::TCall> >::push_front(glslang::TCall&&) /usr/include/c++/10/bits/stl_list.h:1167 KhronosGroup#6 in glslang::TIntermediate::addToCallGraph(TInfoSink&, std::__cxx11::basic_string<char, std::char_traits<char>, glslang::pool_allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, glslang::pool_allocator<char> > const&) glslang/MachineIndependent/Intermediate.cpp:2860 What happens here: 1. TCall's bool fields are not initialized on construction. 2. `push_front` move the `TCall` passed into it. 3. The move constructor copies unitialized bool, which may have an out-of-range value. What this fix does: Calls `emplace_back` to ensure no copy/move constructor is called. Fixes KhronosGroup#2222 Refs KhronosGroup#2112
UBSAN rightly complains on `push_front` here: glslang/MachineIndependent/localintermediate.h:100:8: runtime error: load of value 160, which is not a valid value for type 'bool' #0 in glslang::TCall::TCall(glslang::TCall&&) glslang/MachineIndependent/localintermediate.h:100 KhronosGroup#1 in void __gnu_cxx::new_allocator<std::_List_node<glslang::TCall> >::construct<glslang::TCall, glslang::TCall>(glslang::TCall*, glslang::TCall&&) /usr/include/c++/10/ext/new_allocator.h:150 KhronosGroup#2 in void std::allocator_traits<std::allocator<std::_List_node<glslang::TCall> > >::construct<glslang::TCall, glslang::TCall>(std::allocator<std::_List_node<glslang::TCall> >&, glslang::TCall*, glslang::TCall&&) /usr/include/c++/10/bits/alloc_traits.h:512 KhronosGroup#3 in std::_List_node<glslang::TCall>* std::__cxx11::list<glslang::TCall, std::allocator<glslang::TCall> >::_M_create_node<glslang::TCall>(glslang::TCall&&) (...) KhronosGroup#4 in void std::__cxx11::list<glslang::TCall, std::allocator<glslang::TCall> >::_M_insert<glslang::TCall>(std::_List_iterator<glslang::TCall>, glslang::TCall&&) /usr/include/c++/10/bits/stl_list.h:1911 KhronosGroup#5 in std::__cxx11::list<glslang::TCall, std::allocator<glslang::TCall> >::push_front(glslang::TCall&&) /usr/include/c++/10/bits/stl_list.h:1167 KhronosGroup#6 in glslang::TIntermediate::addToCallGraph(TInfoSink&, std::__cxx11::basic_string<char, std::char_traits<char>, glslang::pool_allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, glslang::pool_allocator<char> > const&) glslang/MachineIndependent/Intermediate.cpp:2860 What happens here: 1. TCall's bool fields are not initialized on construction. 2. `push_front` move the `TCall` passed into it. 3. The move constructor copies unitialized bool, which may have an out-of-range value. What this fix does: Calls `emplace_back` to ensure no copy/move constructor is called. Fixes KhronosGroup#2222 Refs KhronosGroup#2112
This PR fixes the following warnings when compiled with latest clang in Xcode7 on OSX 10.11, there are 2 warnings remaining which I need advice on how to fix (see below).
The tests are running successfully.
There are 2 warnings remaining, these happen because a constant 0xFFFFFFFF is compared against an enum which doesn't contain such a value. To fix this I would need advice what your preferred fix would be, for instance, adding an 'Invalid' entry to the enum which has value 0xFFFFFFFF, or performing a cast of the enum to unsigned int inside the if()...?