Skip to content

Commit ef09c90

Browse files
committed
gcc: fix assert usage in constexpr function
1 parent 5824f81 commit ef09c90

1 file changed

Lines changed: 22 additions & 4 deletions

File tree

include/scn/scan.h

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3777,7 +3777,12 @@ class SCN_TRIVIAL_ABI scan_error {
37773777
return std::errc::result_out_of_range;
37783778
case max_error:
37793779
default:
3780-
assert(false);
3780+
#if !SCN_GCC || SCN_GCC >= SCN_COMPILER(9, 0, 0)
3781+
// gcc 7 thinks we'll get here, even when we won't
3782+
// gcc 8 has a bug in debug mode,
3783+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86678
3784+
SCN_EXPECT(false);
3785+
#endif
37813786
SCN_UNREACHABLE;
37823787
}
37833788
}
@@ -4155,8 +4160,10 @@ inline constexpr char32_t decode_utf8_code_point_exhaustive(
41554160
return cp;
41564161
}
41574162

4158-
#if !SCN_GCC || SCN_GCC >= SCN_COMPILER(8, 0, 0)
4163+
#if !SCN_GCC || SCN_GCC >= SCN_COMPILER(9, 0, 0)
41594164
// gcc 7 thinks we'll get here, even when we won't
4165+
// gcc 8 has a bug in debug mode,
4166+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86678
41604167
SCN_EXPECT(false);
41614168
#endif
41624169
SCN_UNREACHABLE;
@@ -4213,8 +4220,10 @@ inline constexpr char32_t decode_utf8_code_point_exhaustive_valid(
42134220
return cp;
42144221
}
42154222

4216-
#if !SCN_GCC || SCN_GCC >= SCN_COMPILER(8, 0, 0)
4223+
#if !SCN_GCC || SCN_GCC >= SCN_COMPILER(9, 0, 0)
42174224
// gcc 7 thinks we'll get here, even when we won't
4225+
// gcc 8 has a bug in debug mode,
4226+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86678
42184227
SCN_EXPECT(false);
42194228
#endif
42204229
SCN_UNREACHABLE;
@@ -5767,7 +5776,6 @@ constexpr size_t encode_types()
57675776
(encode_types_impl<CharT, Ts...>() << packed_arg_bits);
57685777
}
57695778
else {
5770-
SCN_EXPECT(false);
57715779
SCN_UNREACHABLE;
57725780
}
57735781
}
@@ -6991,7 +6999,12 @@ struct format_specs {
69916999
return 16;
69927000

69937001
default:
7002+
#if !SCN_GCC || SCN_GCC >= SCN_COMPILER(9, 0, 0)
7003+
// gcc 7 thinks we'll get here, even when we won't
7004+
// gcc 8 has a bug in debug mode,
7005+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86678
69947006
SCN_EXPECT(false);
7007+
#endif
69957008
SCN_UNREACHABLE;
69967009
}
69977010
SCN_GCC_COMPAT_POP
@@ -7241,7 +7254,12 @@ constexpr presentation_type parse_presentation_type(CharT type)
72417254
case '/':
72427255
// Should be handled by parse_presentation_set and
72437256
// parse_presentation_regex
7257+
#if !SCN_GCC || SCN_GCC >= SCN_COMPILER(9, 0, 0)
7258+
// gcc 7 thinks we'll get here, even when we won't
7259+
// gcc 8 has a bug in debug mode,
7260+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86678
72447261
SCN_EXPECT(false);
7262+
#endif
72457263
SCN_UNREACHABLE;
72467264
default:
72477265
return presentation_type::none;

0 commit comments

Comments
 (0)