Skip to content

Commit

Permalink
Minor: fix msvc warning "not all control paths return a value"
Browse files Browse the repository at this point in the history
When building with /Od - default cmake debug build for me, the __assume(false); trick does not work to get rid of the C4714 warnings

https://godbolt.org/z/a6xGnfP7d

D:\tmp\cppcheck\lib\keywords.cpp(205): warning C4715: 'Keywords::getOnly': not all control paths return a value
D:\tmp\cppcheck\lib\keywords.cpp(226): warning C4715: 'Keywords::getOnly': not all control paths return a value
D:\tmp\cppcheck\lib\keywords.cpp(168): warning C4715: 'Keywords::getAll': not all control paths return a value
D:\tmp\cppcheck\lib\keywords.cpp(188): warning C4715: 'Keywords::getAll': not all control paths return a value

Proposed fix: also define NORETURN to [[noreturn]] when according to __has_cpp_attribute [[noreturn]] is supported https://en.cppreference.com/w/cpp/feature_test

(For previous discussion see also danmar#5497)
  • Loading branch information
StefanVK committed Nov 11, 2023
1 parent 2d232dc commit 79b6525
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@
# define NORETURN [[noreturn]]
#elif defined(__GNUC__)
# define NORETURN __attribute__((noreturn))
#else
#elif defined __has_cpp_attribute
# if __has_cpp_attribute (noreturn)
# define NORETURN [[noreturn]]
# endif
#endif
#if !defined(NORETURN)
# define NORETURN
#endif

Expand Down

0 comments on commit 79b6525

Please sign in to comment.