Skip to content

Commit

Permalink
馃洜 stringop-overflow bug removal for GCC & friends
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePhD committed Dec 12, 2022
1 parent e4a61be commit cdad528
Show file tree
Hide file tree
Showing 31 changed files with 564 additions and 367 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ if(ZTD_TEXT_IS_TOP_LEVEL_PROJECT)
check_compiler_flag(warn-errors MSVC /WX GCC -Werror)
check_compiler_flag(warn-extra GCC -Wextra Clang -Wextra)
check_compiler_diagnostic(alignas-extra-padding MSVC 4324 LANGUAGES CXX)
# (Wstringop-overflow) - [meta-bug] bogus/missing -Wstringop-overflow warnings
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88443
# Bogus -Wstringop-overflow warning
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100395
# [10 Regression] spurious -Wstringop-overflow writing to a trailing array plus offset
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95353
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
check_compiler_diagnostic(stringop-overflow)
endif()
endif()
endif()

Expand Down
1 change: 1 addition & 0 deletions benchmarks/barrier/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ target_compile_options(ztd.text.benchmarks.barrier
${--warn-extra}
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
)
target_link_libraries(ztd.text.benchmarks.barrier
PRIVATE
Expand Down
1 change: 1 addition & 0 deletions benchmarks/conversion_speed/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function (generate_converion_speed_benchmark_targets name data_name title)
${--warn-extra}
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
)
target_compile_definitions(ztd.text.benchmarks.conversion_speed.${name}
PRIVATE
Expand Down
1 change: 1 addition & 0 deletions benchmarks/function_form/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function (generate_function_form_benchmark_targets name data_name title)
${--warn-all}
${--warn-extra}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
# MSVC is BROKEN
# ${--warn-errors}
)
Expand Down
2 changes: 1 addition & 1 deletion documentation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ set(ZTD_TEXT_DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in)
set(ZTD_TEXT_DOXYFILE_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
set(ZTD_TEXT_SPHINX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/source)
set(ZTD_TEXT_SPHINX_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/sphinx)
set(ZTD_TEXT_SPHINX_INDEX_FILE ${ZTD_TEXT_SPHINX_BUILD_DIR}/index.xml)
set(ZTD_TEXT_SPHINX_INDEX_FILE ${ZTD_TEXT_SPHINX_BUILD_DIR}/index.html)

# Get all Sphinx source files
file(GLOB_RECURSE ztd_text_sphinx_sources
Expand Down
1 change: 1 addition & 0 deletions examples/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ foreach (example_source_name ${ztd.text.examples.basic.sources})
${--warn-extra}
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
)

target_link_libraries(${example_target}
Expand Down
1 change: 1 addition & 0 deletions examples/boost.text/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ target_compile_options(ztd.text.examples.boost_text
${--warn-extra}
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
)

target_include_directories(ztd.text.examples.boost_text
Expand Down
1 change: 1 addition & 0 deletions examples/documentation/compile_fails/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ foreach (example_name ${ztd.text.examples.documentation.compile_fails.sources})
${--warn-extra}
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
)
set_target_properties(${example_target}
PROPERTIES
Expand Down
1 change: 1 addition & 0 deletions examples/documentation/quick/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ foreach (example_source_name ${ztd.text.examples.documentation.quick.basic.sourc
${--warn-extra}
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
)

target_link_libraries(${example_target}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,5 @@

int main(int, char*[]) {

const

return 0;
return 0;
}
1 change: 1 addition & 0 deletions examples/documentation/snippets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ foreach (example_source_name ${ztd.text.examples.documentation.snippets.sources}
${--warn-all}
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
)
target_include_directories(${example_target}
PRIVATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

#include <iostream>

int main(int, char* argv[]) {
int main(int, char*[]) {

std::string utf8_string = ztd::text::transcode(
u"馃寛\xD801\xD802\xD803馃寛馃寛", my_utf16 {}, ztd::text::compat_utf8);
Expand Down
1 change: 1 addition & 0 deletions examples/shift_jis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ target_compile_options(ztd.text.examples.shift_jis
${--warn-extra}
${--warn-errors}
${--allow-alignas-extra-padding}
${--allow-stringop-overflow}
)
target_include_directories(ztd.text.examples.shift_jis
PRIVATE
Expand Down
1 change: 1 addition & 0 deletions include/ztd/text/decode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

#include <string>
#include <vector>
#include <utility>

#include <ztd/prologue.hpp>

Expand Down
2 changes: 1 addition & 1 deletion include/ztd/text/detail/validate_count_routines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace ztd { namespace text {
template <typename _Input, typename _Encoding, typename _Output, typename _DecodeState, typename _EncodeState,
typename _PivotRange>
constexpr auto __basic_validate_decodable_as_one(_Input&& __input, _Encoding&& __encoding, _Output& __output,
_DecodeState& __decode_state, _EncodeState& __encode_state, pivot<_PivotRange> __pivot) {
_DecodeState& __decode_state, _EncodeState& __encode_state, pivot<_PivotRange>& __pivot) {

using _UInput = remove_cvref_t<_Input>;
using _UOutput = remove_cvref_t<_Output>;
Expand Down

0 comments on commit cdad528

Please sign in to comment.