From 470796b5456592ee5179bbd44b72910a2d7f6aca Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Fri, 13 Jul 2012 14:23:27 -0700 Subject: [PATCH] CompatSet: users pass bit indices rather than masks CompatSet users number the Feature objects rather than providing masks. Thus, we should do mask |= (1 << f.id) rather than mask |= f.id. In order to detect old, broken encodings, the lowest bit will be set in memory but not set in the encoding. We can reconstruct the correct mask from the names map. This bug can cause an incompat bit to not be detected since 1|2 == 1|2|3. fixes: #2748 Signed-off-by: Samuel Just --- src/include/CompatSet.h | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/src/include/CompatSet.h b/src/include/CompatSet.h index 1c18d6193a984..b5bf450b97e20 100644 --- a/src/include/CompatSet.h +++ b/src/include/CompatSet.h @@ -33,9 +33,11 @@ struct CompatSet { uint64_t mask; map names; - FeatureSet() : mask(0), names() {} + FeatureSet() : mask(1), names() {} void insert(Feature f) { - mask |= f.id; + assert(f.id > 0); + assert(f.id < 63); + mask |= (1< temp_names; + temp_names.swap(names); + for (map::iterator i = temp_names.begin(); + i != temp_names.end(); + ++i) { + insert(Feature(i->first, i->second)); + } + } else { + mask |= 1; + } } void dump(Formatter *f) const { -- 2.39.5