Hi! While running `make check -j24`, I've seen an internal compiler error. I've tried to reproduce it, but it only triggered once that time.
This is the only log I've been able to collect. I hope it helps.
lto1: internal compiler error: in lto_read_decls, at
lto/lto-common.cc:1970
0x23234de internal_error(char const*, ...)
../.././gcc/diagnostic-global-context.cc:491
0x923807 fancy_abort(char const*, int, char const*)
../.././gcc/diagnostic.cc:1772
0x71d494 lto_read_decls
../.././gcc/lto/lto-common.cc:1970
0x97b959 lto_file_finalize
../.././gcc/lto/lto-common.cc:2299
0x97b959 lto_create_files_from_ids
../.././gcc/lto/lto-common.cc:2309
0x97b959 lto_file_read
../.././gcc/lto/lto-common.cc:2364
0x97b959 read_cgraph_and_symbols(unsigned int, char const**)
../.././gcc/lto/lto-common.cc:2812
0x95c012 lto_main()
../.././gcc/lto/lto.cc:658
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
lto-wrapper: fatal error:
/home/alx/src/gnu/gcc/len/host-x86_64-pc-linux-gnu/gcc/xgcc returned 1 exit
status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
To clarify, this was run after running a slightly-modified version of
this patch set, and nothing else. In theory, I think, I haven't touched
anything that should cause an lto ICE. I've rebased on top of git HEAD
earlier today, and have applied the changes shown below.
I assume I'm causing it somehow, with my patches, but maybe it's not.
Is git HEAD known to be in a bad state at the moment regarding lto?
The range-diff below is what will be v6, which I was planning to send
today, but haven't because of this ICE.
Cheers,
Alex
$ git range-diff 73010cb4af6^..af05d01e68d gnu/master..HEAD
1: 73010cb4af6 = 1: 8b68e250503 gcc/: Rename array_type_nelts() =>
array_type_nelts_minus_one()
2: 9b835478721 = 2: 21433097103 Merge definitions of array_type_nelts_top()
3: af05d01e68d ! 3: e8867c0fef4 c: Add __lengthof__ operator
@@ Commit message
FUTURE DIRECTIONS:
- We could make it work with array parameters to functions, and
- somehow magically return the length designator of the array,
- regardless of it being really a pointer.
+ - We should make it work with array parameters to functions,
+ and somehow magically return the length designator of the array,
+ regardless of it being really a pointer.
+
+ - Fix support for [0].
Cc: Joseph Myers <[email protected]>
Cc: Gabriel Ravier <[email protected]>
@@ Commit message
gcc/testsuite/ChangeLog:
* gcc.dg/lengthof-compile.c:
+ * gcc.dg/lengthof-vla.c:
* gcc.dg/lengthof.c: Add tests for __lengthof__ operator.
Link: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2529.pdf
@@ gcc/c/c-typeck.cc: c_expr_sizeof_type (location_t loc, struct
c_type_name *t)
+static bool
+is_top_array_vla (tree type)
+{
-+ bool zero, var;
++ bool zero, star, var;
+ tree d;
+
+ if (TREE_CODE (type) != ARRAY_TYPE)
@@ gcc/c/c-typeck.cc: c_expr_sizeof_type (location_t loc, struct
c_type_name *t)
+
+ d = TYPE_DOMAIN (type);
+ zero = !TYPE_MAX_VALUE (d);
-+ var = (!zero
-+ && (TREE_CODE (TYPE_MIN_VALUE (d)) != INTEGER_CST
-+ || TREE_CODE (TYPE_MAX_VALUE (d)) != INTEGER_CST));
-+ var = var || (zero && C_TYPE_VARIABLE_SIZE (type));
++ star = (zero && C_TYPE_VARIABLE_SIZE (type));
++ if (star)
++ return true;
++ if (zero)
++ return false;
++
++ var = (TREE_CODE (TYPE_MIN_VALUE (d)) != INTEGER_CST
++ || TREE_CODE (TYPE_MAX_VALUE (d)) != INTEGER_CST);
+ return var;
+}
+
@@ gcc/doc/extend.texi: If the operand of the @code{__alignof__} expression
is a fu
+
+The keyword @code{__lengthof__} determines the length of an array operand,
+that is, the number of elements in the array.
-+Its syntax is just like @code{sizeof}.
-+The operand must be a complete array type.
++Its syntax is similar to @code{sizeof}.
++The operand must be a complete array type or an expression of that type.
++For example:
++
++@smallexample
++int a[n];
++__lengthof__ (a); // returns n
++__lengthof__ (int [7][3]); // returns 7
++@end smallexample
++
+The operand is not evaluated
+if the top-level length designator is an integer constant expression
-+(in this case, the operator results in a constant expression);
++(in this case, the operator results in an integer constant expression);
+and it is evaluated
+if the top-level length designator is not an integer constant expression
+(in this case, the operator results in a run-time value).
+For example:
+
+@smallexample
-+__lengthof__ (int [7][n++]); // constexpr
-+__lengthof__ (int [n++][7]); // run-time value
++__lengthof__ (int [7][n++]); // integer constant expression
++__lengthof__ (int [n++][7]); // run-time value; n++ is evaluated
+@end smallexample
+
@node Inline
@@ gcc/testsuite/gcc.dg/lengthof-compile.c (new)
+
+extern int x[];
+
++static int w[] = {1, 2, 3};
++
++static int z[0];
++static int y[__lengthof__(z)];
++
++void
++automatic(void)
++{
++ __lengthof__ (w);
++}
++
+void
+incomplete (int p[])
+{
-+ unsigned n;
-+
-+ n = __lengthof__ (x); /* { dg-error "incomplete" } */
++ __lengthof__ (x); /* { dg-error "incomplete" } */
+
+ /* We want to support the following one in the future,
+ but for now it should fail. */
-+ n = __lengthof__ (p); /* { dg-error "invalid" } */
++ __lengthof__ (p); /* { dg-error "invalid" } */
+}
+
+void
@@ gcc/testsuite/gcc.dg/lengthof-compile.c (new)
+ int x;
+ int fam[];
+ } s;
-+ unsigned n;
+
-+ n = __lengthof__ (s.fam); /* { dg-error "incomplete" } */
++ __lengthof__ (s.fam); /* { dg-error "incomplete" } */
+}
+
+void fix_fix (int i, char (*a)[3][5], int (*x)[__lengthof__ (*a)]);
@@ gcc/testsuite/gcc.dg/lengthof-compile.c (new)
+ fix_uns (5, &c35, &i3);
+ fix_uns (5, &c35, &i5); /* { dg-error "incompatible-pointer-types" } */
+}
++
++void
++non_arr(void)
++{
++ int x;
++ int *p;
++ struct s {
++ int x[3];
++ } s;
++
++ __lengthof__ (x); /* { dg-error "invalid" } */
++ __lengthof__ (int); /* { dg-error "invalid" } */
++ __lengthof__ (s); /* { dg-error "invalid" } */
++ __lengthof__ (struct s); /* { dg-error "invalid" } */
++ __lengthof__ (&x); /* { dg-error "invalid" } */
++ __lengthof__ (p); /* { dg-error "invalid" } */
++ __lengthof__ (int *); /* { dg-error "invalid" } */
++ __lengthof__ (&s.x); /* { dg-error "invalid" } */
++ __lengthof__ (int (*)[3]); /* { dg-error "invalid" } */
++}
++
++static int f1(), f2();
++int a[10][10];
++int n;
++
++void
++syms(void)
++{
++ int b[n][n];
++
++ __lengthof__ (a[f1()]);
++ __lengthof__ (b[f2()]); /* { dg-warning "never defined" } */
++}
++
++void
++no_parens(void)
++{
++ __lengthof__ a;
++ __lengthof__ *a;
++ __lengthof__ (int [3]) {};
++
++ __lengthof__ int [3]; /* { dg-error "expected expression before" } */
++}
++
++void
++const_expr(void)
++{
++ int n = 7;
++
++ _Static_assert (__lengthof__ (int [3][n]) == 3);
++ _Static_assert (__lengthof__ (int [n][3]) == 7); /* { dg-warning "not
constant"} */
++ _Static_assert (__lengthof__ (int [0][3]) == 0);
++ _Static_assert (__lengthof__ (int [0]) == 0);
++
++ /* FIXME: lengthog(int [0][n]) should result in a constant expression.
*/
++ _Static_assert (__lengthof__ (int [0][n]) == 0); /* { dg-warning "not
constant"} */
++}
+
+ ## gcc/testsuite/gcc.dg/lengthof-vla.c (new) ##
+@@
++/* { dg-do compile } */
++/* { dg-options "-Wno-pedantic -Wvla-parameter" } */
++
++void fix_fix (int i,
++ char (*a)[3][5],
++ int (*x)[__lengthof__ (*a)]);
++void fix_var (int i,
++ char (*a)[3][i], /* dg-warn "variable" */
++ int (*x)[__lengthof__ (*a)]);
++void fix_uns (int i,
++ char (*a)[3][*],
++ int (*x)[__lengthof__ (*a)]);
++
++void zro_fix (int i,
++ char (*a)[0][5],
++ int (*x)[__lengthof__ (*a)]);
++void zro_var (int i,
++ char (*a)[0][i], /* dg-warn "variable" */
++ int (*x)[__lengthof__ (*a)]);
++void zro_uns (int i,
++ char (*a)[0][*],
++ int (*x)[__lengthof__ (*a)]);
++
++void var_fix (int i,
++ char (*a)[i][5], /* dg-warn "variable" */
++ int (*x)[__lengthof__ (*a)]); /* dg-warn "variable" */
++void var_var (int i,
++ char (*a)[i][i], /* dg-warn "variable" */
++ int (*x)[__lengthof__ (*a)]); /* dg-warn "variable" */
++void var_uns (int i,
++ char (*a)[i][*], /* dg-warn "variable" */
++ int (*x)[__lengthof__ (*a)]); /* dg-warn "variable" */
++
++void uns_fix (int i,
++ char (*a)[*][5],
++ int (*x)[__lengthof__ (*a)]);
++void uns_var (int i,
++ char (*a)[*][i], /* dg-warn "variable" */
++ int (*x)[__lengthof__ (*a)]);
++void uns_uns (int i,
++ char (*a)[*][*],
++ int (*x)[__lengthof__ (*a)]);
++
++// Can't test due to bug:
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116284>
++//static int z2[0];
++//static int y2[__lengthof__(z2)];
## gcc/testsuite/gcc.dg/lengthof.c (new) ##
@@
@@ gcc/testsuite/gcc.dg/lengthof.c (new)
+{
+ short a[7];
+
-+ assert (__lengthof__ (a) == 7);
-+ assert (__lengthof__ (long [0]) == 0);
-+ assert (__lengthof__ (unsigned [99]) == 99);
++ static_assert (__lengthof__ (a) == 7);
++ static_assert (__lengthof__ (long [0]) == 0);
++ static_assert (__lengthof__ (unsigned [99]) == 99);
++}
++
++void
++automatic(void)
++{
++ int a[] = {1, 2, 3};
++ int z[] = {};
++
++ static_assert (__lengthof__ (a) == 3);
++ static_assert (__lengthof__ (z) == 0);
+}
+
+void
@@ gcc/testsuite/gcc.dg/lengthof.c (new)
+ int a[8];
+ } s;
+
-+ assert (__lengthof__ (s.a) == 8);
++ static_assert (__lengthof__ (s.a) == 8);
+}
+
+void
@@ gcc/testsuite/gcc.dg/lengthof.c (new)
+ int i;
+
+ i = 3;
-+ assert (__lengthof__ (struct {int x[i++];}[3]) == 3);
++ static_assert (__lengthof__ (struct {int x[i++];}[3]) == 3);
+ assert (i == 3);
+}
+
@@ gcc/testsuite/gcc.dg/lengthof.c (new)
+ long (*p)[__lengthof__ (a)];
+
+ p = &a;
-+ assert (__lengthof__ (*p++) == 5);
++ static_assert (__lengthof__ (*p++) == 5);
+ assert (p == &a);
+}
+
@@ gcc/testsuite/gcc.dg/lengthof.c (new)
+{
+ int i;
+
-+ assert (__lengthof__ (int [0][4]) == 0);
++ static_assert (__lengthof__ (int [0][4]) == 0);
+ i = 3;
+ assert (__lengthof__ (int [0][i]) == 0);
+}
@@ gcc/testsuite/gcc.dg/lengthof.c (new)
+{
+ int i;
+
-+ assert (__lengthof__ (int [7][4]) == 7);
++ static_assert (__lengthof__ (int [7][4]) == 7);
+ i = 3;
-+ assert (__lengthof__ (int [7][i]) == 7);
++ static_assert (__lengthof__ (int [7][i]) == 7);
+}
+
+void
@@ gcc/testsuite/gcc.dg/lengthof.c (new)
+ assert (i == 9 + 1);
+}
+
++void
++no_parens(void)
++{
++ int n = 3;
++ int a[7];
++ int v[n];
++
++ static_assert (__lengthof__ a == 7);
++ assert (__lengthof__ v == 3);
++}
++
+int
+main (void)
+{
+ array ();
++ automatic ();
+ vla ();
+ member ();
+ vla_eval ();
@@ gcc/testsuite/gcc.dg/lengthof.c (new)
+ matrix_zero ();
+ matrix_fixed ();
+ matrix_vla ();
++ no_parens ();
+}
--
<https://www.alejandro-colomar.es/>
signature.asc
Description: PGP signature
