[Bug c++/84639] gcc/c-family/c-attribs.c:1822:27: runtime error: shift exponent -1 is negative
mpolacek at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 1 09:26:00 GMT 2018
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84639
--- Comment #2 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Can be fixed by moving the checking a bit above:
--- a/gcc/c-family/c-attribs.c
+++ b/gcc/c-family/c-attribs.c
@@ -1818,6 +1818,13 @@ common_handle_aligned_attribute (tree *node, tree name,
tree args, int flags,
/* Log2 of specified alignment. */
int pow2align = check_user_alignment (align_expr, true);
+ if (pow2align == -1
+ || !check_cxx_fundamental_alignment_constraints (*node, pow2align,
flags))
+ {
+ *no_add_attrs = true;
+ return NULL_TREE;
+ }
+
/* The alignment in bits corresponding to the specified alignment. */
unsigned bitalign = (1U << pow2align) * BITS_PER_UNIT;
@@ -1826,10 +1833,7 @@ common_handle_aligned_attribute (tree *node, tree name,
tree args, int flags,
unsigned curalign = 0;
unsigned lastalign = 0;
- if (pow2align == -1
- || !check_cxx_fundamental_alignment_constraints (*node, pow2align,
flags))
- *no_add_attrs = true;
- else if (is_type)
+ if (is_type)
{
if ((flags & (int) ATTR_FLAG_TYPE_IN_PLACE))
/* OK, modify the type in place. */;
More information about the Gcc-bugs
mailing list