https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123437
Peter Damianov <peter0x44 at disroot dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |peter0x44 at disroot dot org
--- Comment #4 from Peter Damianov <peter0x44 at disroot dot org> ---
The following patch "fixes" the ICE:
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index 1903285b626..f08e051ad4e 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -14478,8 +14478,10 @@ build_binary_op (location_t location, enum tree_code
code,
if (code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE)
tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
- if (!(((tcode0 == INTEGER_TYPE || tcode0 == BITINT_TYPE)
- && (tcode1 == INTEGER_TYPE || tcode1 == BITINT_TYPE))
+ if (!(((tcode0 == INTEGER_TYPE || tcode0 == BITINT_TYPE
+ || tcode0 == ENUMERAL_TYPE)
+ && (tcode1 == INTEGER_TYPE || tcode1 == BITINT_TYPE
+ || tcode1 == ENUMERAL_TYPE))
|| (tcode0 == FIXED_POINT_TYPE && tcode1 == FIXED_POINT_TYPE)))
resultcode = RDIV_EXPR;
else
diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index f6f71a03003..347ce7de1e0 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -5856,7 +5856,8 @@ cp_build_binary_op (const op_location_t &location,
if (tcode1 == COMPLEX_TYPE || tcode1 == VECTOR_TYPE)
tcode1 = TREE_CODE (TREE_TYPE (TREE_TYPE (op1)));
- if (!(tcode0 == INTEGER_TYPE && tcode1 == INTEGER_TYPE))
+ if (!((tcode0 == INTEGER_TYPE || tcode0 == ENUMERAL_TYPE)
+ && (tcode1 == INTEGER_TYPE || tcode1 == ENUMERAL_TYPE)))
resultcode = RDIV_EXPR;
else
{
But I have doubts it's the correct approach. The reason this doesn't ICE
without using vector is I think because the enums got promoted to int so
typeck.cc is never going to see an ENUMERAL_TYPE in this context.
typedef enum foo vec_foo __attribute__((vector_size(16)));
But the same promotion does NOT appear to be happening to the vector of enum.
WDYT the solution should be?