Skip to content

Fix a few compiler warnings#534

Merged
arch1t3cht merged 5 commits intoTypesettingTools:masterfrom
filip-hejsek:warning_fixes
Feb 6, 2026
Merged

Fix a few compiler warnings#534
arch1t3cht merged 5 commits intoTypesettingTools:masterfrom
filip-hejsek:warning_fixes

Conversation

@filip-hejsek
Copy link
Contributor

See the commit messages for the warnings that are fixed.

(I also decided to replace a few // fallthrough comments in C++ by [[fallthrough]]; attributes. The comments suppress the warnings too, so whether it is an improvement is subjective.)

Fixes the following warning:

../src/hotkey.cpp: In function ‘void {anonymous}::migrate_hotkeys(const char* (*)[3])’:
../src/hotkey.cpp:61:43: warning: comparing the result of pointer addition ‘(added + ((sizetype)(i * 24)))’ and NULL [-Waddress]
   61 |                 for (size_t i = 0; added[i] && added[i][0]; ++i) {
      |                                           ^
Fixes the following warnings:

../libaegisub/common/cajun/reader.cpp: In member function ‘json::UnknownElement json::Reader::ParseObject(TokenStream&)’:
../libaegisub/common/cajun/reader.cpp:282:25: warning: redundant move in return statement [-Wredundant-move]
  282 |         return std::move(object);
      |                ~~~~~~~~~^~~~~~~~
../libaegisub/common/cajun/reader.cpp:282:25: note: remove ‘std::move’ call
../libaegisub/common/cajun/reader.cpp: In member function ‘json::UnknownElement json::Reader::ParseArray(TokenStream&)’:
../libaegisub/common/cajun/reader.cpp:299:25: warning: redundant move in return statement [-Wredundant-move]
  299 |         return std::move(array);
      |                ~~~~~~~~~^~~~~~~
../libaegisub/common/cajun/reader.cpp:299:25: note: remove ‘std::move’ call
Fixes the following warning:

../tests/tests/iconv.cpp: In member function ‘virtual void lagi_iconv_Buffer_Test::TestBody()’:
../tests/tests/iconv.cpp:91:19: warning: overflow in conversion from ‘int’ to ‘std::array<char, 4>::value_type’ {aka ‘char’} changes value from ‘255’ to ‘-1’ [-Woverflow]
   91 |         buff.fill(0xFF);
      |                   ^~~~
Fixes the following warnings:

../src/resolution_resampler.cpp: In function ‘void ResampleResolution(AssFile*, ResampleSettings)’:
../src/resolution_resampler.cpp:242:45: warning: this statement may fall through [-Wimplicit-fallthrough=]
  242 |                         border_horizontally = !border_horizontally;
      |                         ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
../src/resolution_resampler.cpp:243:17: note: here
  243 |                 case ResampleARMode::AddBorder:
      |                 ^~~~
../src/dialog_video_properties.cpp: In function ‘bool {anonymous}::update_video_properties(AssFile*, const AsyncVideoProvider*, wxWindow*)’:
../src/dialog_video_properties.cpp:139:17: warning: this statement may fall through [-Wimplicit-fallthrough=]
  139 |                 if (!ar_changed) {
      |                 ^~
../src/dialog_video_properties.cpp:149:9: note: here
  149 |         case MISMATCH_PROMPT:
      |         ^~~~
We cannot use [[fallthrough]] attribute because that requires C23, but
actually just adding a comment silences the warnings too.

Fixes the following warnings:

../src/MatroskaParser.c: In function ‘myvsnprintf’:
../src/MatroskaParser.c:333:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
  333 |         state = 2;
      |         ~~~~~~^~~
../src/MatroskaParser.c:334:7: note: here
  334 |       case 2:
      |       ^~~~
../src/MatroskaParser.c:339:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
  339 |         state = 3;
      |         ~~~~~~^~~
../src/MatroskaParser.c:340:7: note: here
  340 |       case 3:
      |       ^~~~
../src/MatroskaParser.c:346:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
  346 |         state = 4;
      |         ~~~~~~^~~
../src/MatroskaParser.c:347:7: note: here
  347 |       case 4:
      |       ^~~~
../src/MatroskaParser.c: In function ‘parseBlockGroup’:
../src/MatroskaParser.c:2145:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
 2145 |       len = tmplen = toplen;
      |       ~~~~^~~~~~~~~~~~~~~~~
../src/MatroskaParser.c:2146:5: note: here
 2146 |     case 0xa1: // Block
      |     ^~~~
@arch1t3cht
Copy link
Member

Thanks!

Repeating what I wrote on discord for posterity: Yes, [[fallback]] is preferred for C++ since it also silences the warning for Clang (if one was to enable it there), since Clang does not parse comments here.

@arch1t3cht arch1t3cht merged commit 3695026 into TypesettingTools:master Feb 6, 2026
7 checks passed
@filip-hejsek filip-hejsek deleted the warning_fixes branch February 6, 2026 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants