Skip to content

Commit d2f2abd

Browse files
authored
Fix GCC attribute warning introduced by google#319 (google#320)
`error: 'array-bounds' attribute directive ignored [-Werror=attributes]`
1 parent cd757b1 commit d2f2abd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

include/cctz/civil_time_detail.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@ CONSTEXPR_F int days_per_year(year_t y, month_t m) noexcept {
9292
return is_leap_year(y + (m > 2)) ? 366 : 365;
9393
}
9494
// The compiler cannot optimize away the check if we use
95-
// fsanitize=array-bounds.
95+
// -fsanitize=array-bounds.
9696
// m is guaranteed to be in [1:12] in the caller, but the compiler cannot
9797
// optimize away the check even when this function is inlined into BreakTime.
9898
// To reduce the overhead, we use no_sanitize to skip the unnecessary
99-
// fsanitize=array-bounds check. Remove no_sanitize once the missed
99+
// -fsanitize=array-bounds check. Remove no_sanitize once the missed
100100
// optimization is fixed.
101-
#if defined(__has_attribute)
102-
#if __has_attribute(no_sanitize)
103-
__attribute__((no_sanitize("array-bounds")))
101+
#if defined(__clang__) && defined(__has_cpp_attribute)
102+
#if __has_cpp_attribute(clang::no_sanitize)
103+
[[clang::no_sanitize("array-bounds")]]
104104
#endif
105105
#endif
106106
CONSTEXPR_F int days_per_month(year_t y, month_t m) noexcept {

0 commit comments

Comments
 (0)