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

GCC compiler warning about violating the C++ One Definition Rule [-Wodr] #4116

Closed
1 of 2 tasks
mgerhardy opened this issue Aug 21, 2023 · 1 comment
Closed
1 of 2 tasks

Comments

@mgerhardy
Copy link

mgerhardy commented Aug 21, 2023

Description

/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:***8475:***: warning: type ‘union json_value’ violates the C++ One Definition Rule [-Wodr]
***8475 |     union json_value
      |           ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:***8475:***: note: a different type is defined in another translation unit
***8475 |     union json_value
      |           ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:***8478:***9: note: the first difference of corresponding definitions is field ‘object’
***8478 |         object_t* object;
      |                   ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:***8478:***9: note: a field of same name but different type is defined in another translation unit
***8478 |         object_t* object;
      |                   ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:***8475:***: note: type name ‘std::map<std::__cxx***::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::basic_json<std::map, std::vector, std::__cxx***::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, std::less<void>, std::allocator<std::pair<std::__cxx***::basic_string<char, std::char_traits<char>, std::allocator<char> > const, nlohmann::basic_json<std::map, std::vector, std::__cxx***::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > > > >’ should match type name ‘std::map<std::__cxx***::basic_string<char, std::char_traits<char>, std::allocator<char> >, nlohmann::basic_json<std::map, std::vector, std::__cxx***::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >, std::less<std::__cxx***::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::__cxx***::basic_string<char, std::char_traits<char>, std::allocator<char> > const, nlohmann::basic_json<std::map, std::vector, std::__cxx***::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > > > > >’
***8475 |     union json_value
      |           ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:***7677:7: warning: type ‘struct basic_json’ violates the C++ One Definition Rule [-Wodr]
***7677 | class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions)
      |       ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:***7677:7: note: a different type is defined in another translation unit
***7677 | class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions)
      |       ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:247***4:***6: note: the first difference of corresponding definitions is field ‘m_value’
247***4 |     json_value m_value = {};
      |                ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:247***4:***6: note: a field of same name but different type is defined in another translation unit
247***4 |     json_value m_value = {};
      |                ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:***8475:***: note: type ‘union json_value’ itself violates the C++ One Definition Rule
***8475 |     union json_value
      |           ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:***7677:7: note: type ‘struct basic_json’ itself violates the C++ One Definition Rule
***7677 | class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions)
      |       ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:6240:7: warning: type ‘struct json_sax_dom_callback_parser’ violates the C++ One Definition Rule [-Wodr]
 6240 | class json_sax_dom_callback_parser
      |       ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:6240:7: note: a different type is defined in another translation unit
 6240 | class json_sax_dom_callback_parser
      |       ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:6543:***9: note: the first difference of corresponding definitions is field ‘discarded’
 6543 |     BasicJsonType discarded = BasicJsonType::value_t::discarded;
      |                   ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:6543:***9: note: a field of same name but different type is defined in another translation unit
 6543 |     BasicJsonType discarded = BasicJsonType::value_t::discarded;
      |                   ^
/home/runner/work/vengi/vengi/contrib/libs/json/json.hpp:***7677:7: note: type ‘struct basic_json’ itself violates the C++ One Definition Rule
***7677 | class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions)
      |       ^

Reproduction steps

Compile with gcc and -Wodr

Expected vs. actual results

no warnings

Minimal code example

No response

Error messages

No response

Compiler and operating system

gcc/linux

Library version

v3.10.4

Validation

@mgerhardy
Copy link
Author

sorry, the warning comes with tinygltf - i will open a ticket there to update the lib first.

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

1 participant