From 8230755bfd65268b735c38815dec7852a302f731 Mon Sep 17 00:00:00 2001 From: Aaron Gyes Date: Tue, 24 Sep 2019 23:34:10 -0700 Subject: [PATCH] Make sure rgb_color_t doesn't grow For years the comment above the class claimed it was 4 bytes, but it had grown to 5. Add a static_assert() to prevent that from happening again. --- src/color.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/color.h b/src/color.h index edc2f1d46..02d98e80a 100644 --- a/src/color.h +++ b/src/color.h @@ -13,7 +13,8 @@ struct color24_t { unsigned char rgb[3]; }; -/// A type that represents a color. We work hard to keep it at a size of 4 bytes. +/// A type that represents a color. We work hard to keep it at a size of 4 bytes and verify with +/// static_assert class rgb_color_t { // Types enum { type_none, type_named, type_rgb, type_normal, type_reset }; @@ -169,4 +170,6 @@ class rgb_color_t { static wcstring_list_t named_color_names(void); }; +static_assert(sizeof(rgb_color_t) <= 4, "rgb_color_t is too big"); + #endif