diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index e1b4b65dd662f6cded0c15105c9f0bb8e98e807c..6c11654a2c65b54500d44f5077716929593224c0 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7643,7 +7643,9 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT *pbitsize,
       /* Reject out-of-bound accesses (PR79731).  */
       || (! AGGREGATE_TYPE_P (TREE_TYPE (inner))
 	  && compare_tree_int (TYPE_SIZE (TREE_TYPE (inner)),
-			       bp + bs) < 0))
+			       bp + bs) < 0)
+      || (INTEGRAL_TYPE_P (TREE_TYPE (inner))
+	  && !type_has_mode_precision_p (TREE_TYPE (inner))))
     return NULL_TREE;
 
   *pbitsize = bs;
diff --git a/gcc/testsuite/gcc.dg/bitint-119.c b/gcc/testsuite/gcc.dg/bitint-119.c
new file mode 100644
index 0000000000000000000000000000000000000000..8283d50b3a689d09d7f7c673f55f4570bd0badb8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bitint-119.c
@@ -0,0 +1,11 @@
+/* PR tree-optimization/118023 */
+/* { dg-do compile { target bitint } } */
+/* { dg-options "-O2" } */
+
+_BitInt(63) b;
+
+int
+foo (void)
+{
+  return !*(_Complex char *) &b;
+}