Summary: | gcc/c-family/c-attribs.c:1822:27: runtime error: shift exponent -1 is negative | ||
---|---|---|---|
Product: | gcc | Reporter: | Martin Liška <marxin> |
Component: | c++ | Assignee: | Marek Polacek <mpolacek> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | jason, nathan |
Priority: | P3 | ||
Version: | 8.0.1 | ||
Target Milestone: | --- | ||
Host: | Target: | x86_64-*-*, i?86-*-* | |
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2018-03-01 00:00:00 | |
Bug Depends on: | |||
Bug Blocks: | 63426 |
Description
Martin Liška
2018-03-01 08:02:12 UTC
Confirmed with an assert. 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. */; Author: mpolacek Date: Thu Mar 1 19:15:42 2018 New Revision: 258109 URL: https://gcc.gnu.org/viewcvs?rev=258109&root=gcc&view=rev Log: PR c++/84639 * c-attribs.c (common_handle_aligned_attribute): Don't use invalid alignment in computation. Modified: trunk/gcc/c-family/ChangeLog trunk/gcc/c-family/c-attribs.c Fixed in GCC 8. |