[Bug middle-end/102464] Miss optimization for (_Float16) sqrtf ((float) f16)

2021-09-22 Thread crazylht at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102464

--- Comment #1 from Hongtao.liu  ---
Similar optimization also applies for
fma
fmax/fmin
fabs
ldexp
ceil
floor
trunc
round
rint
nearbyint
copysign

Since AVX512-FP16 has corresponding instructions.

[Bug middle-end/102464] New: Miss optimization for (_Float16) sqrtf ((float) f16)

2021-09-22 Thread crazylht at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102464

Bug ID: 102464
   Summary: Miss optimization for (_Float16) sqrtf ((float) f16)
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: missed-optimization
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: crazylht at gmail dot com
  Target Milestone: ---
Target: x86_64-*-* i?86-*-*

Related thread
[1] https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574216.html
[2] https://gcc.gnu.org/pipermail/gcc-patches/2021-July/574330.html

[Bug target/89954] missed optimization for signed extension for x86-64

2021-09-22 Thread crazylht at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89954

--- Comment #9 from Hongtao.liu  ---
(In reply to Hongtao.liu from comment #8)
> (In reply to Uroš Bizjak from comment #7)
> > Created attachment 51496 [details]
> > Prototype patch
> 
> +;; convert (sign_extend:WIDE (any_logic:NARROW (memory, immediate)))
> +;; to (any_logic:WIDE (sign_extend (memory)), (sign_extend (immediate))).
> +;; This eliminates sign extension after logic operation.
> +
> +(define_split
> +  [(set (match_operand:SWI248 0 "register_operand")
> + (sign_extend:SWI248
> +   (any_logic:QI (match_operand:QI 1 "memory_operand")
> + (match_operand:QI 2 "const_int_operand"]
> +  ""
> +  [(set (match_dup 0) (any_logic:SWI248 (match_dup 0) (match_dup 2)))]
> +  "convert_move (operands[0], operands[1], false);")
> 
> Shouldn't we make sure (any_logic op1 const_int) would change sign bit of
> op1?
Typo, would not change sign bit of op1.

[Bug target/89954] missed optimization for signed extension for x86-64

2021-09-22 Thread crazylht at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89954

--- Comment #8 from Hongtao.liu  ---
(In reply to Uroš Bizjak from comment #7)
> Created attachment 51496 [details]
> Prototype patch

+;; convert (sign_extend:WIDE (any_logic:NARROW (memory, immediate)))
+;; to (any_logic:WIDE (sign_extend (memory)), (sign_extend (immediate))).
+;; This eliminates sign extension after logic operation.
+
+(define_split
+  [(set (match_operand:SWI248 0 "register_operand")
+   (sign_extend:SWI248
+ (any_logic:QI (match_operand:QI 1 "memory_operand")
+   (match_operand:QI 2 "const_int_operand"]
+  ""
+  [(set (match_dup 0) (any_logic:SWI248 (match_dup 0) (match_dup 2)))]
+  "convert_move (operands[0], operands[1], false);")

Shouldn't we make sure (any_logic op1 const_int) would change sign bit of op1?

[Bug c/102463] [12 Regression] ice in fold_using_range::relation_fold_and_or

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102463

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |12.0
   Severity|normal  |blocker
   Keywords||ice-on-valid-code
Summary|ice in  |[12 Regression] ice in
   |fold_using_range::relation_ |fold_using_range::relation_
   |fold_and_or |fold_and_or

[Bug c/102463] New: ice in fold_using_range::relation_fold_and_or

2021-09-22 Thread dcb314 at hotmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102463

Bug ID: 102463
   Summary: ice in fold_using_range::relation_fold_and_or
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

For this C code:

_bfd_elf_merge_symbol_h, _bfd_elf_merge_symbol_h_1;
_Bool _bfd_elf_merge_symbol_olddef;
_bfd_elf_merge_symbol() {
  _Bool newdef = bfd_is_com_section(), ntdef, tdef;
  _bfd_elf_merge_symbol_olddef = _bfd_elf_merge_symbol_h;
  if (_bfd_elf_merge_symbol_h_1) {
ntdef = newdef;
tdef = _bfd_elf_merge_symbol_h;
  } else {
ntdef = _bfd_elf_merge_symbol_h;
tdef = newdef;
  }
  if (tdef && ntdef)
;
}

compiled by recent gcc and flag -O2, does this:

during GIMPLE pass: evrp
elflink.c: In function ‘_bfd_elf_merge_symbol’:
elflink.c:15198:1: internal compiler error: Segmentation fault
0xd6a899 crash_signal(int)
../../trunk.git/gcc/toplev.c:328
0x1a73c3c fold_using_range::relation_fold_and_or(irange&, gimple*, fur_source&)
../../trunk.git/gcc/gimple-range-fold.cc:1365

The problem first seems to occur sometime between git hash
947332a4e22aef9b, from last week, and hash 83aac698835edcdb
from yesterday.

[Bug tree-optimization/102462] vectorization breaks diagnostic for array out of bound detect.

2021-09-22 Thread crazylht at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102462

--- Comment #1 from Hongtao.liu  ---
The issue also exists for O3

[Bug c/79412] [9/10/11/12 Regression] ICE in fold_convert_loc, at fold-const.c:2239

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79412

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|9.5 |12.0
 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #17 from Andrew Pinski  ---
Fixed on the trunk for GCC 12.

[Bug tree-optimization/102462] New: vectorizer breaks diagnostic for array out of bound detect.

2021-09-22 Thread crazylht at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102462

Bug ID: 102462
   Summary: vectorizer breaks diagnostic for array out of bound
detect.
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: diagnostic
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: crazylht at gmail dot com
  Target Milestone: ---

> > Yes, there are quite a few warning tests like that.  Their main
> > purpose is to verify that in common GCC invocations (i.e., without
> > any special options) warnings are a) issued when expected and b)
> > not issued when not expected.  Otherwise, middle end warnings are
> > known to have both false positives and false negatives in some
> > invocations, depending on what optimizations are in effect.
> > Indiscriminately disabling common optimizations for these large
> > tests and invoking them under artificial conditions would
> > compromise this goal and hide the problems.
> >
> > If enabling vectorization at -O2 causes regressions in the quality
> > of diagnostics (as the test failure above indicates seems to be
> > happening) we should investigate these and open bugs for them so
> > they can be fixed.  We can then tweak the specific failing test
> > cases to avoid the failures until they are fixed.

There're 3 cases.

1. All accesses are out of bound, and after vectorization, there are
some warnings missing.(Because there only 1 access after vectorization, 2
accesses w/o vectorization, and diagnostic is based on access).
2. Part of accesses are inbound, part of accesses are out of bound,
and after vectorization, the warning goes from out of bound line to
inbound line.
3. All access are out of bound, and after vectoriation, all warning
are missing, and goes to a false-positive line.


below is case3:

> void ga1i_1 (void)
> {
>   a1i_1.a[0] = 0;
>   a1i_1.a[1] = 1;   // { dg-warning "\\\[-Wstringop-overflow" }
>   a1i_1.a[2] = 2;   // { dg-warning "\\\[-Wstringop-overflow" }
>
>   struct A1 a = { 0, { 1 } }; --- false positive here.
>   a.a[0] = 1;
>   a.a[1] = 2;   // { dg-warning "\\\[-Wstringop-overflow" } 
> false negative here.
>   a.a[2] = 3;   // { dg-warning "\\\[-Wstringop-overflow" } 
> false negative here.
>   sink ();
> }


Related testcases.

* c-c++-common/Wstringop-overflow-2.c
* gcc.dg/Warray-bounds-51.c: Ditto.
* gcc.dg/Wstringop-overflow-14.c: Ditto.
* gcc.dg/Wstringop-overflow-21.c: Ditto.

[Bug c/94726] [10/11/12 Regression] ICE in uniform_vector_p, at tree.c:11214 since r10-2089-g21caa1a2649d586f

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94726

Andrew Pinski  changed:

   What|Removed |Added

 Status|NEW |ASSIGNED
   Assignee|unassigned at gcc dot gnu.org  |pinskia at gcc dot 
gnu.org

--- Comment #9 from Andrew Pinski  ---
I have a simple fix.
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 9163dcda438..943c5cb8f2d 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -6232,6 +6232,9 @@ gimplify_save_expr (tree *expr_p, gimple_seq *pre_p,
gimple_seq *post_p)
   gcc_assert (TREE_CODE (*expr_p) == SAVE_EXPR);
   val = TREE_OPERAND (*expr_p, 0);

+  if (TREE_TYPE (val) == error_mark_node)
+return GS_ERROR;
+
   /* If the SAVE_EXPR has not been resolved, then evaluate it once.  */
   if (!SAVE_EXPR_RESOLVED_P (*expr_p))
 {

[Bug c/94726] [10/11/12 Regression] ICE in uniform_vector_p, at tree.c:11214 since r10-2089-g21caa1a2649d586f

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94726

--- Comment #8 from Andrew Pinski  ---
After r12-3278-g823685221de986a, the ICE moved slightly:


t.c:13:8: error: conflicting types for ‘a’; have ‘void *[]’
   13 | void * a [ ] = { } ;
  |^
t.c:5:6: note: previous declaration of ‘a’ with type ‘type’ {aka ‘__vector(2)
unsigned int’}
5 | type a , b;
  |  ^
t.c: In function ‘foo’:
t.c:9:13: internal compiler error: tree check: expected class ‘type’, have
‘exceptional’ (error_mark) in create_tmp_from_val, at gimplify.c:568
9 | b = __builtin_shuffle ( a , var ) ;
  | ^
0x6a9973 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
/home/ubuntu/src/upstream-gcc-aarch64/gcc/gcc/tree.c:8739
0xa9548f tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
/home/ubuntu/src/upstream-gcc-aarch64/gcc/gcc/tree.h:3546
0xa9548f create_tmp_from_val
/home/ubuntu/src/upstream-gcc-aarch64/gcc/gcc/gimplify.c:568
0xa9548f lookup_tmp_var
/home/ubuntu/src/upstream-gcc-aarch64/gcc/gcc/gimplify.c:601
0xa9548f internal_get_tmp_var
/home/ubuntu/src/upstream-gcc-aarch64/gcc/gcc/gimplify.c:640
0xa98b83 get_initialized_tmp_var(tree_node*, gimple**, gimple**, bool)
/home/ubuntu/src/upstream-gcc-aarch64/gcc/gcc/gimplify.c:679
0xa98b83 gimplify_save_expr
/home/ubuntu/src/upstream-gcc-aarch64/gcc/gcc/gimplify.c:6251
0xa8f2ff gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/home/ubuntu/src/upstream-gcc-aarch64/gcc/gcc/gimplify.c:14857
0xa8e39b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
/home/ubuntu/src/upstream-gcc-aarch64/gcc/gcc/gimplify.c:15335

[Bug middle-end/87118] ICE in expand_expr_addr_expr_1 with __transaction_relaxed and bitfields

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87118

Andrew Pinski  changed:

   What|Removed |Added

 CC||gsocshubham at gmail dot com

--- Comment #7 from Andrew Pinski  ---
*** Bug 89351 has been marked as a duplicate of this bug. ***

[Bug middle-end/89351] internal compiler error: in exact_div, at poly-int.h:2139 with -fgnu-tm

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89351

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|--- |DUPLICATE
 Status|NEW |RESOLVED

--- Comment #3 from Andrew Pinski  ---
Dup of bug 87118.

*** This bug has been marked as a duplicate of bug 87118 ***

[Bug middle-end/87118] ICE in expand_expr_addr_expr_1 with __transaction_relaxed and bitfields

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87118

Andrew Pinski  changed:

   What|Removed |Added

Summary|ICE in  |ICE in
   |expand_expr_addr_expr_1, at |expand_expr_addr_expr_1
   |expr.c:7862 |with __transaction_relaxed
   ||and bitfields

--- Comment #6 from Andrew Pinski  ---
Here is a testcase which shows the issue is related to bitfields:
struct {
  unsigned a: 7;
  unsigned b : 3;
} b;

void d(int t) {}
void c() {
  __transaction_relaxed { d(b.b); }
}

[Bug c++/84964] [9/10/11/12 Regression] ICE in expand_call, at calls.c:4540

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84964

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=56344

--- Comment #13 from Andrew Pinski  ---
The sorry was added by r0-126979 (aka PR 56344).

[Bug c++/84964] [9/10/11/12 Regression] ICE in expand_call, at calls.c:4540

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84964

--- Comment #12 from Andrew Pinski  ---
A little history here:

4.1.2 accepted the code without an ICE.

4.4-4.7 had an ICE:
:2:8: internal compiler error: in tree_low_cst, at tree.h:4435

4.8 accepted the code without an ICE.

4.9-7 had the sorry:
:5:16: sorry, unimplemented: passing too large argument on stack

8+ had the ICE after the sorry:
:5:16: internal compiler error: in expand_call, at calls.c:3919

[Bug tree-optimization/102451] Suspicious null-pointer dereference in delete_dead_or_redundant_call

2021-09-22 Thread fxue at os dot amperecomputing.com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102451

--- Comment #2 from Feng Xue  ---
(In reply to Richard Biener from comment #1)
> Confirmed.  Mind fixing it by recording the basic-block index before
> removing/replacing?

OK.

[Bug fortran/101319] Missing diagnostic for argument with type parameters for assumed-type dummy

2021-09-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101319

--- Comment #1 from CVS Commits  ---
The master branch has been updated by Sandra Loosemore :

https://gcc.gnu.org/g:5098e7077bfcace3e80144e63c81be94546ced16

commit r12-3828-g5098e7077bfcace3e80144e63c81be94546ced16
Author: Sandra Loosemore 
Date:   Wed Sep 22 07:49:17 2021 -0700

Fortran: diagnostic for argument w/type parameters for assumed-type dummy

2021-09-22  Sandra Loosemore  

PR fortran/101319

gcc/fortran/
* interface.c (gfc_compare_actual_formal): Extend existing
assumed-type diagnostic to also check for argument with type
parameters.

gcc/testsuite/
* gfortran.dg/c-interop/assumed-type-dummy.f90: Remove xfail.

[Bug fortran/101334] gfortran fails to enforce C838 on disallowed uses of assumed-rank variable names + bogus errors

2021-09-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101334

--- Comment #1 from CVS Commits  ---
The master branch has been updated by Sandra Loosemore :

https://gcc.gnu.org/g:7a40f2e74815a926c5f47416c29efbc17aa1ef43

commit r12-3827-g7a40f2e74815a926c5f47416c29efbc17aa1ef43
Author: Sandra Loosemore 
Date:   Sun Sep 19 17:32:03 2021 -0700

Fortran: Fixes for F2018 C838 (PR fortran/101334)

The compiler was failing to diagnose the error required by F2018 C838
when passing an assumed-rank array argument to a non-assumed-rank dummy.
It was also incorrectly giving an error for calls to the 2-argument form
of the ASSOCIATED intrinsic, which is supposed to be permitted by C838.

2021-09-19  Sandra Loosemore  

PR fortran/101334

gcc/fortran/
* check.c (gfc_check_associated): Allow an assumed-rank
array for the pointer argument.
* interface.c (compare_parameter): Also give rank mismatch
error on assumed-rank array.

gcc/testsuite/
* gfortran.dg/c-interop/c535b-2.f90: Remove xfails.
* gfortran.dg/c-interop/c535b-3.f90: Likewise.

[Bug middle-end/80270] [9/10/11/12 Regression ICE in extract_bit_field_1 at gcc/expmed.c:1798

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80270

Andrew Pinski  changed:

   What|Removed |Added

Summary|ICE in extract_bit_field_1  |[9/10/11/12 Regression ICE
   |at gcc/expmed.c:1798|in extract_bit_field_1 at
   ||gcc/expmed.c:1798
   Target Milestone|--- |9.5
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=80173
   Keywords|ice-on-valid-code   |ice-on-invalid-code

--- Comment #5 from Andrew Pinski  ---
Related to PR 80173.  The difference between that bug and this one is simple:
b.s2f1.s1f[i];
vs 
b.s2f1.s1f[3];

[Bug middle-end/80270] ICE in extract_bit_field_1 at gcc/expmed.c:1798

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80270

Andrew Pinski  changed:

   What|Removed |Added

  Known to fail||4.8.1

--- Comment #4 from Andrew Pinski  ---
Interesting GCC 4.7's C front-end rejected this by:
:20:22: error: data type of 'b' isn't suitable for a register

But the C++ front-end rejected this due to not having vector[i] being
implemented.

[Bug fortran/102458] ICE tree check: expected array_type, have pointer_type in gfc_conv_array_initializer, at fortran/trans-array.c:6136

2021-09-22 Thread sgk at troutmask dot apl.washington.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102458

--- Comment #8 from Steve Kargl  ---
On Wed, Sep 22, 2021 at 09:17:18PM +, anlauf at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102458
> 
> anlauf at gcc dot gnu.org changed:
> 
>What|Removed |Added
> 
>   Attachment #51497|0   |1
> is obsolete||
> 
> --- Comment #7 from anlauf at gcc dot gnu.org ---
> Created attachment 51498
>   --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51498=edit
> Revised patch including testcase
> 

I think TRANSFER needs to be handled differently.

>From the same section of the Fortran standard, TRANSFER is
rejected if the following does not apply.

   (8) a reference to the intrinsic function TRANSFER where each
   argument is a constant expression and each ultimate pointer
   component of the SOURCE argument is disassociated,

So, one should be able to do something like

   integer,parameter :: n = 4
   integer,parameter :: x(transfer(n, n)) = 1
   print *, x
   end

which gfortran will give 

% gfortran10 -o z a.f90
% ./z
   1   1   1   1

If you remove TRANSFER from the patch, it looks good to me.
We can revisit TRANSFER when Gerhard breaks gfortran, again! ;-)

[Bug c/102461] overflow in omp parallel for schedule (static,chunk_size)

2021-09-22 Thread michelemartone at users dot sourceforge.net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102461

--- Comment #3 from Michele Martone  ---
Created attachment 51502
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51502=edit
patched gcc *ompexp file with the OMP region tree.

I am attaching patched gcc *ompexp file with the OMP region tree. Notice the
negative values checks.

[Bug c/102461] overflow in omp parallel for schedule (static,chunk_size)

2021-09-22 Thread michelemartone at users dot sourceforge.net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102461

--- Comment #2 from Michele Martone  ---
Created attachment 51501
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51501=edit
original *ompexp file with the OMP region tree

I am attaching original *ompexp file with the OMP region tree.

[Bug c/102461] overflow in omp parallel for schedule (static,chunk_size)

2021-09-22 Thread michelemartone at users dot sourceforge.net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102461

Michele Martone  changed:

   What|Removed |Added

 CC||michelemartone at users dot 
source
   ||forge.net

--- Comment #1 from Michele Martone  ---
Created attachment 51500
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51500=edit
a slightly longer reproducer listing

I add a slightly longer reproducer listing.

[Bug c/102461] New: overflow in omp parallel for schedule (static,chunk_size)

2021-09-22 Thread michelemartone at users dot sourceforge.net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102461

Bug ID: 102461
   Summary: overflow in omp parallel for schedule
(static,chunk_size)
   Product: gcc
   Version: 11.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: michelemartone at users dot sourceforge.net
  Target Milestone: ---

Created attachment 51499
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51499=edit
`git diff` output of gcc/omp-expand.c against revision 7ca388565af aka tag:
releases/gcc-11.2.0

Hi,

I am the author of the LIBRSB library [http://librsb.sourceforge.net/] for
Sparse BLAS (sparse linear algebra_ computations.
I've received a bug report [https://savannah.gnu.org/bugs/?60042#comment4]
where an OpenMP-parallelized loop between i=0.. ended up
executing the loop body with i=-1.

The original loop in question had static scheduling and chunk_size=1, and
even one thread is sufficient to cause the problem.

I reduced the problem and can reproduce it with gcc-11.2.0 (built from sources,
GIT tag releases/gcc-11.2.0) and older ones; arch x86_64.
I could not reproduce the problem with clang-11.0.1 or icc-19.0.5.281.  

// # gcc -Wall -Wextra -pedantic -fopenmp -std=c11 -O0 overflow.c   
#include  // abort
#include  // INT_MAX
#include  // compile with -fopenmp
int main ()
{ 
  const int chunk_size = 1000; 
  const int n = INT_MAX - 100; // 2147483547
  int l = 0;
  #pragma omp parallel for schedule (static,chunk_size) num_threads (1)
  for (int i = 0; i < n; ++i)
{ 
  l = i; 
  if(i < 0)
abort ();
}
  if ( l != n-1 )
abort ();
  return 0;
}

I made some experiments in gcc/omp-expand.c and came up with a fix to insert
overflow detection code when computing the lower and upper boundaries of the
current chunk, thus avoiding the loop body from being executed with i=-1.
Invoking patched gcc like:

FIX1=1 FIX2=1 FIX3=1 gcc -fopenmp -Wall -pedantic -O0 overflow_mini.c -o
overflow -fdump-tree-all

and looking at the *.ompexp file it dumps, one can get an idea of what was
going wrong with the original flow.

Unfortunately I was not able to make my patch generate correct code for -O1 or
more.

I am attaching `git diff` output of gcc/omp-expand.c against revision
7ca388565af aka tag: releases/gcc-11.2.0 -- so one may use this as a base to
fix the bug fully.

I hope this information is enough for you GCC/OpenMP folks to fix this problem!

Michele

[Bug fortran/102458] ICE tree check: expected array_type, have pointer_type in gfc_conv_array_initializer, at fortran/trans-array.c:6136

2021-09-22 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102458

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

  Attachment #51497|0   |1
is obsolete||

--- Comment #7 from anlauf at gcc dot gnu.org ---
Created attachment 51498
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51498=edit
Revised patch including testcase

This regtests ok and has the right logic.

[Bug c++/80987] Existence of a std::initializer_list constructor breaks deduction guides

2021-09-22 Thread ppalka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80987

Patrick Palka  changed:

   What|Removed |Added

 CC||ppalka at gcc dot gnu.org
   Target Milestone|--- |8.0
 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #2 from Patrick Palka  ---
Fixed ever since r8-1965.

[Bug fortran/102458] ICE tree check: expected array_type, have pointer_type in gfc_conv_array_initializer, at fortran/trans-array.c:6136

2021-09-22 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102458

--- Comment #6 from anlauf at gcc dot gnu.org ---
Created attachment 51497
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51497=edit
Patch

Thanks for the research, Steve.

The attached patch fixes the PR by excluding the listed functions.

[Bug rtl-optimization/78778] non-atomic load moved to before atomic load with std::memory_order_acquire

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78778

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |8.0

--- Comment #6 from Andrew Pinski  ---
(In reply to Andrew Pinski from comment #5)
> Fixed by r8-2879 aka PR 57448 (and others).

I should say fixed for GCC 8+.

[Bug rtl-optimization/78778] non-atomic load moved to before atomic load with std::memory_order_acquire

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78778

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #5 from Andrew Pinski  ---
Fixed by r8-2879 aka PR 57448 (and others).

[Bug target/101543] extra zeroing of empty struct argument/return value

2021-09-22 Thread gabravier at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101543

--- Comment #4 from Gabriel Ravier  ---
Nevermind, didn't see this was an aarch64 bug

[Bug target/101543] extra zeroing of empty struct argument/return value

2021-09-22 Thread gabravier at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101543

Gabriel Ravier  changed:

   What|Removed |Added

 CC||gabravier at gmail dot com

--- Comment #3 from Gabriel Ravier  ---
Seems to be fixed on trunk.

[Bug rtl-optimization/7061] Access of bytes in struct parameters

2021-09-22 Thread gabravier at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7061

Gabriel Ravier  changed:

   What|Removed |Added

 CC||gabravier at gmail dot com

--- Comment #7 from Gabriel Ravier  ---
Compiling this under ia64 seems to now be optimized perfectly as of at least
GCC 10, though the other ones look like they're still badly handled.

[Bug fortran/102458] ICE tree check: expected array_type, have pointer_type in gfc_conv_array_initializer, at fortran/trans-array.c:6136

2021-09-22 Thread kargl at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102458

--- Comment #5 from kargl at gcc dot gnu.org ---
(In reply to kargl from comment #3)
> (In reply to anlauf from comment #2)
> > I think the problem is we consider command_argument_count() as a pure
> > function,
> > so that gfc_is_constant_expr returns true.
> 
> Well, it is a pure function.  Fortran 2018, page 327,
> 
> All standard intrinsic functions are pure.

I think we need to look at the specific function in gfc_is_constant_expr.

The Fortran standard has

   10.1.12 Constant expression

  A constant expression is an expression with limitations that make
  it suitable for use as a kind type parameter, initializer, or named
  constant. It is an expression in which each operation is intrinsic,
  and each primary is
  ...
  (5) a reference to an elemental standard intrinsic function, where
  each argument is a constant expression,

  (6) a reference to a standard intrinsic function that is
  transformational, other than COMMAND_ARGUMENT_COUNT, GET_TEAM,
  NULL, NUM_IMAGES, TEAM_NUMBER, THIS_IMAGE, or TRANSFER, where
  each argument is a constant expression,

So, if I untangle (6), gfortran needs to reject the listed intrinsic
function except for TRANSFER where a different restrict applies.

[Bug fortran/102458] ICE tree check: expected array_type, have pointer_type in gfc_conv_array_initializer, at fortran/trans-array.c:6136

2021-09-22 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102458

--- Comment #4 from anlauf at gcc dot gnu.org ---
(In reply to kargl from comment #3)
> Well, it is a pure function.  Fortran 2018, page 327,
> 
> All standard intrinsic functions are pure.

Of course you are correct.  I wanted to express that in this context one
cannot interpret PURE == (compile time) constant.

[Bug fortran/102458] ICE tree check: expected array_type, have pointer_type in gfc_conv_array_initializer, at fortran/trans-array.c:6136

2021-09-22 Thread kargl at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102458

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 CC||kargl at gcc dot gnu.org

--- Comment #3 from kargl at gcc dot gnu.org ---
(In reply to anlauf from comment #2)
> I think the problem is we consider command_argument_count() as a pure
> function,
> so that gfc_is_constant_expr returns true.

Well, it is a pure function.  Fortran 2018, page 327,

All standard intrinsic functions are pure.

[Bug fortran/102456] ICE in gfc_check_rank, at fortran/check.c:4594

2021-09-22 Thread kargl at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102456

kargl at gcc dot gnu.org changed:

   What|Removed |Added

 CC||kargl at gcc dot gnu.org
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
   Priority|P3  |P4
   Last reconfirmed||2021-09-22

--- Comment #1 from kargl at gcc dot gnu.org ---
The following diff stops the ICE, which is a null pointer dereference.

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 851af1b30dc..2a250d73a28 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -4589,9 +4589,14 @@ gfc_check_rank (gfc_expr *a)

   /* Functions returning pointers are regarded as variable, cf. F2008, R602. 
*/
   if (a->expr_type == EXPR_FUNCTION)
-is_variable = a->value.function.esym
- ? a->value.function.esym->result->attr.pointer
- : a->symtree->n.sym->result->attr.pointer;
+{
+  if (a->value.function.esym && a->value.function.esym->result)
+   is_variable = a->value.function.esym->result->attr.pointer;
+  else if (a->symtree->n.sym->result)
+   is_variable = a->symtree->n.sym->result->attr.pointer;
+  else
+   is_variable = false;
+}

   if (a->expr_type == EXPR_OP
   || a->expr_type == EXPR_NULL

But, the patch yields

% gfcx -c -fcoarray=lib a.f90
a.f90:6:17:

6 |print *, rank(x[1])
  | 1
Error: The argument of the RANK intrinsic at (1) must be a data object

and Gerhard indicates the code is legal.  I don't use coarrays say cannot
confirm or deny this assertion.  I do note that if one pokes around in
gdb that one finds

(gdb) p *a->value.function.actual->expr->symtree->n.sym->as 
$11 = {rank = 0, corank = 1, type = AS_EXPLICIT, cotype = AS_EXPLICIT, 
  lower = {0x203627620, 0x0 }, upper = {
0x0 }, cray_pointee = false, cp_was_assumed = false, 
  resolved = true}

which is the only place I can locate rank and corank info.  I'll also
note that we do have

(gdb) p a->rank
$13 = 0

[Bug fortran/102458] ICE tree check: expected array_type, have pointer_type in gfc_conv_array_initializer, at fortran/trans-array.c:6136

2021-09-22 Thread anlauf at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102458

anlauf at gcc dot gnu.org changed:

   What|Removed |Added

 CC||anlauf at gcc dot gnu.org
   Last reconfirmed||2021-09-22
 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW

--- Comment #2 from anlauf at gcc dot gnu.org ---
I think the problem is we consider command_argument_count() as a pure function,
so that gfc_is_constant_expr returns true.

As a consequence, is_non_constant_shape_array thinks that 'a' has constant
shape,
thus erroneously allowing the initialization.

We need a better concept of "constant"...

[Bug target/89954] missed optimization for signed extension for x86-64

2021-09-22 Thread ubizjak at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89954

--- Comment #7 from Uroš Bizjak  ---
Created attachment 51496
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51496=edit
Prototype patch

[Bug fortran/55534] -Wno-missing-include-dirs does not work with gfortran

2021-09-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55534

--- Comment #15 from CVS Commits  ---
The master branch has been updated by Tobias Burnus :

https://gcc.gnu.org/g:83aac698835edcdb3e6d96b856bef1c5f92e5e24

commit r12-3825-g83aac698835edcdb3e6d96b856bef1c5f92e5e24
Author: Tobias Burnus 
Date:   Wed Sep 22 20:58:35 2021 +0200

Fortran: Improve -Wmissing-include-dirs warnings [PR55534]

It turned out that enabling the -Wmissing-include-dirs for libcpp did
output
too many warnings â at least as run with -B and similar options during
the
GCC build and warning for internal include dirs like finclude, unlikely of
relevance to for a real-world user.
This patch now only warns for -I and -J by default but permits to get the
full warnings including libcpp ones with -Wmissing-include-dirs. It
additionally documents this in the manual.

With that change, the -Wno-missing-include-dirs could be removed
from libgfortran's configure and libgomp's testsuite always cflags.
This reverts those bits of the previous
commit r12-3722-g417ea5c02cef7f000e66d1af22b066c2c1cda047

Additionally, it turned out that all call to load_file called exit
explicitly - except for the main file via gfc_init -> gfc_new_file. The
latter also output a file not existing fatal error, such that two errors
where printed. Now exit is called in line with the other users of
load_file.

Finally, when compileing with "nonexisting/file.f90", first a warning that
"nonexisting" does not exist as include path was printed before the file
not found error was printed. Now the directory in which the physical file
is located is added silently, relying on the file-not-found diagnostic for
those.

PR fortran/55534
gcc/ChangeLog:

* doc/invoke.texi (-Wno-missing-include-dirs.): Document Fortran
behavior.

gcc/fortran/ChangeLog:

* cpp.c (gfc_cpp_register_include_paths, gfc_cpp_post_options):
Add new bool verbose_missing_dir_warn argument.
* cpp.h (gfc_cpp_post_options): Update prototype.
* f95-lang.c (gfc_init): Remove duplicated file-not found diag.
* gfortran.h (gfc_check_include_dirs): Takes bool
verbose_missing_dir_warn arg.
(gfc_new_file): Returns now void.
* options.c (gfc_post_options): Update to warn for -I and -J,
only, by default but for all when user requested.
* scanner.c (gfc_do_check_include_dir):
(gfc_do_check_include_dirs, gfc_check_include_dirs): Take bool
verbose warn arg and update to avoid printing the same message
twice or never.
(load_file): Fix indent.
(gfc_new_file): Return void and exit when load_file failed
as all other load_file users do.

libgfortran/ChangeLog:

* configure.ac (AM_FCFLAGS): Revert r12-3722 by removing
-Wno-missing-include-dirs.
* configure: Regenerate.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/fortran.exp (ALWAYS_CFLAGS): Revert
r12-3722 by removing -Wno-missing-include-dirs.
* testsuite/libgomp.oacc-fortran/fortran.exp (ALWAYS_CFLAGS):
Likewise.

gcc/testsuite/ChangeLog:

* gfortran.dg/include_14.f90: Add -J testcase and update dg-output.
* gfortran.dg/include_15.f90: Likewise.
* gfortran.dg/include_16.f90: Likewise.
* gfortran.dg/include_17.f90: Likewise.
* gfortran.dg/include_18.f90: Likewise.
* gfortran.dg/include_19.f90: Likewise.

[Bug tree-optimization/102448] [12 Regression] wrong codegen in gcc in spec2017 since 24f99147b9264f8f7d9cfb2fa6bd431edfa252d2

2021-09-22 Thread tnfchris at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102448

--- Comment #2 from Tamar Christina  ---
I have double checked the revision and it does start happening with it.

Though I can only reproduce it with -flto.  the codegen without lto seems the
same.

Any ideas how to debug further?

[Bug fortran/102459] [12 Regression] ICE in gfc_conv_scalarized_array_ref, at fortran/trans-array.c:3549

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102459

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |12.0

[Bug middle-end/98865] Missed transform of (a >> 63) * b

2021-09-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98865

--- Comment #5 from CVS Commits  ---
The master branch has been updated by Roger Sayle :

https://gcc.gnu.org/g:8f571e64713cc72561f84241863496e473eae4c6

commit r12-3824-g8f571e64713cc72561f84241863496e473eae4c6
Author: Roger Sayle 
Date:   Wed Sep 22 19:17:49 2021 +0100

More NEGATE_EXPR folding in match.pd

As observed by Jakub in comment #2 of PR 98865, the expression -(a>>63)
is optimized in GENERIC but not in GIMPLE.  Investigating further it
turns out that this is one of a few transformations performed by
fold_negate_expr in fold-const.c that aren't yet performed by match.pd.
This patch moves/duplicates them there, and should be relatively safe
as these transformations are already performed by the compiler, but
just in different passes.

This revised patch adds a Boolean simplify argument to tree-ssa-sccvn.c's
vn_nary_build_or_lookup_1 to control whether simplification should be
performed before value numbering, updating the callers, but then
avoiding simplification when constructing/value-numbering NEGATE_EXPR.
This avoids the regression of gcc.dg/tree-ssa/ssa-free-88.c, and enables
the new test case(s) to pass.

2021-09-22  Roger Sayle  
Richard Biener  

gcc/ChangeLog
* match.pd (negation simplifications): Implement some negation
folding transformations from fold-const.c's fold_negate_expr.
* tree-ssa-sccvn.c (vn_nary_build_or_lookup_1): Add a SIMPLIFY
argument, to control whether the op should be simplified prior
to looking up/assigning a value number.
(vn_nary_build_or_lookup): Update call to
vn_nary_build_or_lookup_1.
(vn_nary_simplify): Likewise.
(visit_nary_op): Likewise, but when constructing a NEGATE_EXPR
now call vn_nary_build_or_lookup_1 disabling simplification.

gcc/testsuite/ChangeLog
* gcc.dg/fold-negate-1.c: New test case.

[Bug rtl-optimization/102147] IRA dependent on 32-bit vs 64-bit pointer size

2021-09-22 Thread vmakarov at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102147

--- Comment #7 from Vladimir Makarov  ---
I've been thinking about ways to fix this problem but only come to the
following patch.  The patch results in working mostly the same for 64-bit
targets and different for 32-bit targets. In any case the profitability is only
an estimation so I think the patch is ok.  Avoiding 4 stage bootstrap is more
important than a bit slower RA on 32-bit targets (which is questionable) on few
border cases.

I am going to commit the patch this Friday.

--- a/gcc/ira-build.c
+++ b/gcc/ira-build.c
@@ -629,7 +629,7 @@ ior_hard_reg_conflicts (ira_allocno_t a, const_hard_reg_set
set)
 bool
 ira_conflict_vector_profitable_p (ira_object_t obj, int num)
 {
-  int nw;
+  int nbytes;
   int max = OBJECT_MAX (obj);
   int min = OBJECT_MIN (obj);

@@ -638,9 +638,14 @@ ira_conflict_vector_profitable_p (ira_object_t obj, int
num)
in allocation.  */
 return false;

-  nw = (max - min + IRA_INT_BITS) / IRA_INT_BITS;
-  return (2 * sizeof (ira_object_t) * (num + 1)
- < 3 * nw * sizeof (IRA_INT_TYPE));
+  nbytes = (max - min) / 8 + 1;
+  STATIC_ASSERT (sizeof (ira_object_t) <= 8);
+  /* Don't use sizeof (ira_object_t), use constant 8.  Size of ira_object_t (a
+ pointer) is different on 32-bit and 64-bit targets.  Usage sizeof
+ (ira_object_t) can result in different code generation by GCC built as
32-
+ and 64-bit program.  In any case the profitability is just an estimation
+ and border cases are rare.  */
+  return (2 * 8 /* sizeof (ira_object_t) */ * (num + 1) < 3 * nbytes);
 }

 /* Allocates and initialize the conflict vector of OBJ for NUM

[Bug c++/102455] ICE in verify_ctor_sanity with vector types in constexpr and variable template

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102455

Andrew Pinski  changed:

   What|Removed |Added

 Ever confirmed|0   |1
Summary|ICE in verify_ctor_sanity   |ICE in verify_ctor_sanity
   |with vector types in|with vector types in
   |constexpr   |constexpr and variable
   ||template
 Status|UNCONFIRMED |NEW
   Keywords||ice-on-valid-code
   Last reconfirmed||2021-09-22

--- Comment #1 from Andrew Pinski  ---
The infinite loop is not needed:
typedef int v4si;
typedef float v4sf __attribute__ ((vector_size(4)));
constexpr v4sf foo (v4si a) { return (v4sf)a;}
template  constexpr v4sf b = foo (v4si {});

[Bug fortran/102460] New: fortran internal compile error in coverage.c

2021-09-22 Thread davidsch at fedoraproject dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102460

Bug ID: 102460
   Summary: fortran internal compile error in coverage.c
   Product: gcc
   Version: 11.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: davidsch at fedoraproject dot org
  Target Milestone: ---

Created attachment 51495
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51495=edit
two source files and the compile commands to reproduce the issue

the exact version of GCC:
gcc-gfortran-11.2.1-1.fc34.x86_64
GNU Fortran (GCC) 11.2.1 20210728 (Red Hat 11.2.1-1)

the system type:
Fedora 34

the options given when GCC was configured/built:
Not sure, Fedoras default

the complete command line that triggers the bug:
f95 -ftest-coverage -save-temps -c MOD2.f

the compiler output (error messages, warnings, etc.):
during IPA pass: profile
MOD2.f:6:9:

6 |   USE MOD1,only : f1
  | ^
internal compiler error: in coverage_begin_function, at coverage.c:662
Please submit a full bug report,
with preprocessed source if appropriate.

the preprocessed file (*.i*) that triggers the bug:
No *.i* files are generated.

I have attached two source files and the compile commands as attachment.

PS: I have observed the same issue on debian with gcc 10, while gcc 8 works.
PPS: Without coverage instruction, no error is raised.

[Bug c++/102454] [12 Regression] ICE in gimplify_var_or_parm_decl, at gimplify.c:2958

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102454

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |12.0

[Bug ipa/102452] Structs with flexible array members are not optimized on stack

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102452

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||missed-optimization
 CC||marxin at gcc dot gnu.org
  Component|c   |ipa

--- Comment #1 from Andrew Pinski  ---
The difference shows up during inlining 

[Bug fortran/102459] New: [12 Regression] ICE in gfc_conv_scalarized_array_ref, at fortran/trans-array.c:3549

2021-09-22 Thread gscfq--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102459

Bug ID: 102459
   Summary: [12 Regression] ICE in gfc_conv_scalarized_array_ref,
at fortran/trans-array.c:3549
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gs...@t-online.de
  Target Milestone: ---

Started between 20210523 and 20210530, with an array a :


$ cat z1.f90
program p
   type t
  integer :: a(2)
   end type
   type(t) :: x(8)
   !$omp task depend (iterator(j=1:8), out:x(j)%a)
   !$omp end task
end


$ gfortran-12-20210919 -c z1.f90 -fopenmp
z1.f90:6:50:

6 |!$omp task depend (iterator(j=1:8), out:x(j)%a)
  |  1
internal compiler error: Segmentation fault
0xe2831f crash_signal
../../gcc/toplev.c:328
0x7d88a6 gfc_conv_scalarized_array_ref
../../gcc/fortran/trans-array.c:3549
0x7d95c4 gfc_conv_array_ref(gfc_se*, gfc_array_ref*, gfc_expr*, locus*)
../../gcc/fortran/trans-array.c:3700
0x81b5ce gfc_conv_variable
../../gcc/fortran/trans-expr.c:3093
0x81623a gfc_conv_expr(gfc_se*, gfc_expr*)
../../gcc/fortran/trans-expr.c:9041
0x820212 gfc_conv_expr_reference(gfc_se*, gfc_expr*, bool)
../../gcc/fortran/trans-expr.c:9141
0x85e1e4 gfc_trans_omp_clauses
../../gcc/fortran/trans-openmp.c:2864
0x867ae8 gfc_trans_omp_task
../../gcc/fortran/trans-openmp.c:6380
0x867ae8 gfc_trans_omp_directive(gfc_code*)
../../gcc/fortran/trans-openmp.c:7206
0x7d1857 trans_code
../../gcc/fortran/trans.c:2212
0x804a75 gfc_generate_function_code(gfc_namespace*)
../../gcc/fortran/trans-decl.c:6919
0x77be66 translate_all_program_units
../../gcc/fortran/parse.c:6572
0x77be66 gfc_parse_file()
../../gcc/fortran/parse.c:6841
0x7c90df gfc_be_parse_file
../../gcc/fortran/f95-lang.c:216

[Bug fortran/102458] ICE tree check: expected array_type, have pointer_type in gfc_conv_array_initializer, at fortran/trans-array.c:6136

2021-09-22 Thread gscfq--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102458

G. Steinmetz  changed:

   What|Removed |Added

   Keywords||ice-on-invalid-code

--- Comment #1 from G. Steinmetz  ---

There are several variants :


$ cat z3.f90
subroutine s
   integer :: a(num_images()) = 1
   print *, a
end


$ cat z4.f90
subroutine s
   integer :: a(this_image()) = 1
   print *, a
end


$ cat z7.f90
subroutine s
   integer :: a(command_argument_count()) = 1
   a = 2
end


$ cat z8.f90
program p
   block
  integer :: a(command_argument_count()) = 1
  print *, a
   end block
end


$ cat za.f90
function f()
   integer :: a(command_argument_count()) = 0
   a = 1
end


$ cat zb.f90
program p
   block
  integer :: n(command_argument_count()) = 0
  n = 1
   end block
end


$ gfortran-12-20210919 -c zb.f90
zb.f90:3:44:

3 |   integer :: n(command_argument_count()) = 0
  |1
internal compiler error: in gfc_trans_auto_array_allocation, at
fortran/trans-array.c:6426
0x797a5b gfc_trans_auto_array_allocation(tree_node*, gfc_symbol*,
gfc_wrapped_block*)
../../gcc/fortran/trans-array.c:6426
0x7b1f17 gfc_trans_deferred_vars(gfc_symbol*, gfc_wrapped_block*)
../../gcc/fortran/trans-decl.c:4921
0x8054e1 gfc_trans_block_construct(gfc_code*)
../../gcc/fortran/trans-stmt.c:2311
0x78e4a7 trans_code
../../gcc/fortran/trans.c:2014
0x7b4c04 gfc_generate_function_code(gfc_namespace*)
../../gcc/fortran/trans-decl.c:6919
0x73af76 translate_all_program_units
../../gcc/fortran/parse.c:6572
0x73af76 gfc_parse_file()
../../gcc/fortran/parse.c:6841
0x78761f gfc_be_parse_file
../../gcc/fortran/f95-lang.c:216

[Bug fortran/102458] New: ICE tree check: expected array_type, have pointer_type in gfc_conv_array_initializer, at fortran/trans-array.c:6136

2021-09-22 Thread gscfq--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102458

Bug ID: 102458
   Summary: ICE tree check: expected array_type, have pointer_type
in gfc_conv_array_initializer, at
fortran/trans-array.c:6136
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gs...@t-online.de
  Target Milestone: ---

Affects versions down to at least r5 :


$ cat z1.f90
subroutine s
   integer :: a(command_argument_count()) = 1
   print *, a
end


$ gfortran-12-20210919 -c z1.f90
z1.f90:1:12:

1 | subroutine s
  |1
internal compiler error: tree check: expected array_type, have pointer_type in
gfc_conv_array_initializer, at fortran/trans-array.c:6136
0x6938d8 tree_check_failed(tree_node const*, char const*, int, char const*,
...)
../../gcc/tree.c:8689
0x7de241 tree_check(tree_node*, char const*, int, char const*, tree_code)
../../gcc/tree.h:3427
0x7de241 gfc_conv_array_initializer(tree_node*, gfc_expr*)
../../gcc/fortran/trans-array.c:6133
0x81f1b0 gfc_conv_initializer(gfc_expr*, gfc_typespec*, tree_node*, bool, bool,
bool)
../../gcc/fortran/trans-expr.c:8014
0x7ff6ca gfc_get_symbol_decl(gfc_symbol*)
../../gcc/fortran/trans-decl.c:1940
0x80324f generate_local_decl
../../gcc/fortran/trans-decl.c:5989
0x7b3592 do_traverse_symtree
../../gcc/fortran/symbol.c:4170
0x80479c generate_local_vars
../../gcc/fortran/trans-decl.c:6195
0x80479c gfc_generate_function_code(gfc_namespace*)
../../gcc/fortran/trans-decl.c:6854
0x77be66 translate_all_program_units
../../gcc/fortran/parse.c:6572
0x77be66 gfc_parse_file()
../../gcc/fortran/parse.c:6841
0x7c90df gfc_be_parse_file
../../gcc/fortran/f95-lang.c:216

[Bug fortran/102457] New: [PDT] ICE in fold_convert_const_int_from_real, at fold-const.c:2034

2021-09-22 Thread gscfq--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102457

Bug ID: 102457
   Summary: [PDT] ICE in fold_convert_const_int_from_real, at
fold-const.c:2034
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gs...@t-online.de
  Target Milestone: ---

Started with r8 (type mismatch/non-constant) :


$ cat z1.f90
subroutine s
   real :: m = 2
   type t(n)
  integer, len :: n = 1
  character(n*n) :: c
   end type
   type(t(m)) :: x
   call h(x)
end


$ gfortran-12-20210919 -c z1.f90 -O2
during GIMPLE pass: ccp
z1.f90:1:12:

1 | subroutine s
  |^
internal compiler error: in fold_convert_const_int_from_real, at
fold-const.c:2034
0x98904b fold_convert_const_int_from_real
../../gcc/fold-const.c:2034
0x98904b fold_convert_const
../../gcc/fold-const.c:2280
0x99f05d const_unop(tree_code, tree_node*, tree_node*)
../../gcc/fold-const.c:1741
0x10773fe gimple_resimplify1
../../gcc/gimple-match-head.c:212
0x11ab337 gimple_simplify(gimple*, gimple_match_op*, gimple**, tree_node*
(*)(tree_node*), tree_node* (*)(tree_node*))
../../gcc/gimple-match-head.c:948
0x9d289f gimple_fold_stmt_to_constant_1(gimple*, tree_node* (*)(tree_node*),
tree_node* (*)(tree_node*))
../../gcc/gimple-fold.c:7350
0xd6e279 ccp_fold
../../gcc/tree-ssa-ccp.c:1289
0xd6e279 evaluate_stmt
../../gcc/tree-ssa-ccp.c:2207
0xd6f92d visit_assignment
../../gcc/tree-ssa-ccp.c:2840
0xdfaad3 ssa_propagation_engine::simulate_stmt(gimple*)
../../gcc/tree-ssa-propagate.c:230
0xdfad4a ssa_propagation_engine::simulate_block(basic_block_def*)
../../gcc/tree-ssa-propagate.c:337
0xdfb252 ssa_propagation_engine::ssa_propagate()
../../gcc/tree-ssa-propagate.c:504
0xd65725 do_ssa_ccp
../../gcc/tree-ssa-ccp.c:2959
0xd65725 execute
../../gcc/tree-ssa-ccp.c:3003

---

z1.f90:1:12:

1 | subroutine s
  |^
Error: type mismatch in binary expression
integer(kind=4)

real(kind=4)

real(kind=4)

_5 = m.1_3 * m.2_4;
z1.f90:1:12: internal compiler error: 'verify_gimple' failed
0xe7461d verify_gimple_in_seq(gimple*)
../../gcc/tree-cfg.c:5228
0xb16a51 gimplify_body(tree_node*, bool)
../../gcc/gimplify.c:15897
0xb16cf7 gimplify_function_tree(tree_node*)
../../gcc/gimplify.c:15968
0x9338c7 cgraph_node::analyze()
../../gcc/cgraphunit.c:670
0x936a86 analyze_functions
../../gcc/cgraphunit.c:1234
0x937c8d symbol_table::finalize_compilation_unit()
../../gcc/cgraphunit.c:2508

[Bug fortran/102456] New: ICE in gfc_check_rank, at fortran/check.c:4594

2021-09-22 Thread gscfq--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102456

Bug ID: 102456
   Summary: ICE in gfc_check_rank, at fortran/check.c:4594
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gs...@t-online.de
  Target Milestone: ---

Affects versions down to at least r5 :


$ cat z1.f90
program p
   type t
  integer :: a
   end type
   type(t) :: x[*]
   print *, rank(x[1])
end


$ gfortran-12-20210919 -c z1.f90 -fcoarray=single
$
$ gfortran-12-20210919 -c z1.f90 -fcoarray=lib
f951: internal compiler error: Segmentation fault
0xc8446f crash_signal
../../gcc/toplev.c:328
0x6afceb gfc_check_rank(gfc_expr*)
../../gcc/fortran/check.c:4594
0x6eddf9 do_check
../../gcc/fortran/intrinsic.c:4786
0x6eddf9 check_specific
../../gcc/fortran/intrinsic.c:4799
0x6f81b4 gfc_intrinsic_func_interface(gfc_expr*, int)
../../gcc/fortran/intrinsic.c:5036
0x74a859 resolve_unknown_f
../../gcc/fortran/resolve.c:2937
0x74a859 resolve_function
../../gcc/fortran/resolve.c:3281
0x74a859 gfc_resolve_expr(gfc_expr*)
../../gcc/fortran/resolve.c:7115
0x750d44 gfc_resolve_expr(gfc_expr*)
../../gcc/fortran/resolve.c:7082
0x750d44 gfc_resolve_code(gfc_code*, gfc_namespace*)
../../gcc/fortran/resolve.c:11876
0x74f68f gfc_resolve_blocks(gfc_code*, gfc_namespace*)
../../gcc/fortran/resolve.c:10892
0x74fa58 gfc_resolve_code(gfc_code*, gfc_namespace*)
../../gcc/fortran/resolve.c:11866
0x752397 resolve_codes
../../gcc/fortran/resolve.c:17479
0x75245e gfc_resolve(gfc_namespace*)
../../gcc/fortran/resolve.c:17514
0x73a874 resolve_all_program_units
../../gcc/fortran/parse.c:6511
0x73a874 gfc_parse_file()
../../gcc/fortran/parse.c:6763
0x78761f gfc_be_parse_file
../../gcc/fortran/f95-lang.c:216

[Bug c++/102455] New: ICE in verify_ctor_sanity, at cp/constexpr.c:4451

2021-09-22 Thread gscfq--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102455

Bug ID: 102455
   Summary: ICE in verify_ctor_sanity, at cp/constexpr.c:4451
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gs...@t-online.de
  Target Milestone: ---

Affects versions down to at least r5 (with -std=c++14) :


$ cat z1.cc
typedef int v4si;
typedef float v4sf __attribute__ ((vector_size(4)));
constexpr v4sf foo (v4si) { for (;;) {} }
template  constexpr v4sf b = foo (v4si {});


$ g++-12-20210919 -c z1.cc
z1.cc:4:49: internal compiler error: in verify_ctor_sanity, at
cp/constexpr.c:4451
4 | template  constexpr v4sf b = foo (v4si {});
  | ^
0x6e1221 verify_ctor_sanity
../../gcc/cp/constexpr.c:4450
0x6ef919 cxx_eval_bare_aggregate
../../gcc/cp/constexpr.c:4493
0x6e5e73 cxx_eval_constant_expression
../../gcc/cp/constexpr.c:6793
0x6e353b cxx_bind_parameters_in_call
../../gcc/cp/constexpr.c:1644
0x6e353b cxx_eval_call_expression
../../gcc/cp/constexpr.c:2617
0x6e7174 cxx_eval_constant_expression
../../gcc/cp/constexpr.c:6336
0x6e5bb5 cxx_eval_constant_expression
../../gcc/cp/constexpr.c:6828
0x6e964b cxx_eval_outermost_constant_expr
../../gcc/cp/constexpr.c:7368
0x6ec82a fold_non_dependent_expr_template
../../gcc/cp/constexpr.c:7720
0x87abb4 store_init_value(tree_node*, tree_node*, vec**, int)
../../gcc/cp/typeck2.c:777
0x73210d check_initializer
../../gcc/cp/decl.c:7277
0x734457 cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
../../gcc/cp/decl.c:8077
0x7f3caf cp_parser_init_declarator
../../gcc/cp/parser.c:22665
0x7f6ba6 cp_parser_single_declaration
../../gcc/cp/parser.c:31569
0x7f6dc5 cp_parser_template_declaration_after_parameters
../../gcc/cp/parser.c:31134
0x7f758b cp_parser_explicit_template_declaration
../../gcc/cp/parser.c:31400
0x7f758b cp_parser_template_declaration_after_export
../../gcc/cp/parser.c:31419
0x7f97e9 cp_parser_declaration
../../gcc/cp/parser.c:14750
0x7fa4ab cp_parser_translation_unit
../../gcc/cp/parser.c:4978
0x7fa4ab c_parse_file()
../../gcc/cp/parser.c:47694

[Bug c++/102454] New: [12 Regression] ICE in gimplify_var_or_parm_decl, at gimplify.c:2958

2021-09-22 Thread asolokha at gmx dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102454

Bug ID: 102454
   Summary: [12 Regression] ICE in gimplify_var_or_parm_decl, at
gimplify.c:2958
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: asolokha at gmx dot com
  Target Milestone: ---

g++-12.0.0-alpha20210919 snapshot (g:32731fa5b0abf092029b8e2be64319b978bda514)
ICEs when compiling the following testcase, reduced from
gcc/testsuite/g++.dg/coroutines/torture/co-yield-04-complex-local-state.C, w/
-fcoroutines -fno-exceptions:

#include 
#include 

template 
struct looper {
  struct promise_type {
auto get_return_object () { return handle_type::from_promise (*this); }
auto initial_suspend () { return suspend_always_prt {}; }
auto final_suspend () noexcept { return suspend_always_prt {}; }
void return_value (T);
void unhandled_exception ();
  };

  using handle_type = std::coroutine_handle;

  looper (handle_type);

  struct suspend_always_prt {
bool await_ready () noexcept;
void await_suspend (handle_type) noexcept;
void await_resume () noexcept;
  };
};

template 
looper
with_ctorable_state (T)
{
  co_return T ();
}

auto
foo ()
{
  return with_ctorable_state;
}

% g++-12.0.0 -fcoroutines -fno-exceptions -c n7pshqai.C
n7pshqai.C: In function 'looper with_ctorable_state(T) [with T =
std::__cxx11::basic_string]':
n7pshqai.C:27:1: internal compiler error: in gimplify_var_or_parm_decl, at
gimplify.c:2958
   27 | with_ctorable_state (T)
  | ^~~
0x7984d0 gimplify_var_or_parm_decl
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:2958
0xe96100 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:15029
0xeaefd3 gimplify_modify_expr
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:5960
0xe960ed gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:14568
0xeb0f2b gimplify_cleanup_point_expr
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:7006
0xe964f1 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:14961
0xe999d6 gimplify_stmt(tree_node**, gimple**)
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:7006
0xe9746b gimplify_statement_list
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:1997
0xe9746b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:15013
0xe999d6 gimplify_stmt(tree_node**, gimple**)
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:7006
0xe9a28f gimplify_bind_expr
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:1426
0xe967b4 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*),
int)
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:14769
0xeb04d6 gimplify_stmt(tree_node**, gimple**)
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:7006
0xeb04d6 gimplify_body(tree_node*, bool)
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:15814
0xeb094d gimplify_function_tree(tree_node*)
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/gimplify.c:15968
0xcce107 cgraph_node::analyze()
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/cgraphunit.c:670
0xcd0d57 analyze_functions
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/cgraphunit.c:1234
0xcd1a3d symbol_table::finalize_compilation_unit()
   
/var/tmp/portage/sys-devel/gcc-12.0.0_alpha20210919/work/gcc-12-20210919/gcc/cgraphunit.c:2508

[Bug c++/102412] Template argument deduction fails when using concept as defaulted non-type template parameter

2021-09-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102412

--- Comment #2 from CVS Commits  ---
The master branch has been updated by Patrick Palka :

https://gcc.gnu.org/g:9329344a6d81a6a5e3bd171167ebc7b158bb44f4

commit r12-3822-g9329344a6d81a6a5e3bd171167ebc7b158bb44f4
Author: Patrick Palka 
Date:   Wed Sep 22 11:16:53 2021 -0400

c++: concept-ids and value-dependence [PR102412]

The problem here is that uses_template_parms returns true for all
concept-ids (even those with non-dependent arguments), so when a concept-id
is used as a default template argument then during deduction the default
argument is considered dependent even after substituting into it, which
leads to deduction failure (from type_unification_real).

This patch fixes this by implementing the resolution of CWG 2446 which
says a concept-id is dependent only if its arguments are.

DR 2446
PR c++/102412

gcc/cp/ChangeLog:

* constexpr.c (cxx_eval_constant_expression)
: Check value_dependent_expression_p
instead of processing_template_decl.
* pt.c (value_dependent_expression_p) :
Return true only if any_dependent_template_arguments_p.
(instantiation_dependent_r) : Remove this case.
: Likewise.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-nondep2.C: New test.
* g++.dg/cpp2a/concepts-nondep3.C: New test.

[Bug middle-end/102453] buffer overflow by atomic built-ins not diagnosed

2021-09-22 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102453

Martin Sebor  changed:

   What|Removed |Added

   Assignee|unassigned at gcc dot gnu.org  |msebor at gcc dot 
gnu.org
 Status|UNCONFIRMED |ASSIGNED
   Keywords||diagnostic
 Blocks||56456
 Ever confirmed|0   |1
   Last reconfirmed||2021-09-22


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56456
[Bug 56456] [meta-bug] bogus/missing -Warray-bounds

[Bug middle-end/102453] New: buffer overflow by atomic built-ins not diagnosed

2021-09-22 Thread msebor at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102453

Bug ID: 102453
   Summary: buffer overflow by atomic built-ins not diagnosed
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The buffer overflow by the straight assignment in f() below is diagnosed as
expected but the equivalent overflow by the atomic built-in in g() is not even
though both should be.  The problem is simply that due to an oversight, the
access warnings lack support for atomic built-ins.

$ cat y.c && gcc -O2 -S -Wall -fdump-tree-optimized=/dev/stdout y.c
extern _Atomic char x;

void f (void)
{
  long *p = (long*)

  *p = 0;
}

void g (void)
{
  long *p = (long*)

  __atomic_store_n (p, 0, 0);
}
y.c: In function ‘f’:
y.c:7:3: warning: array subscript ‘long int[0]’ is partly outside array bounds
of ‘_Atomic char[1]’ [-Warray-bounds]
7 |   *p = 0;
  |   ^~
y.c:1:21: note: object ‘x’ of size 1
1 | extern _Atomic char x;
  | ^

;; Function f (f, funcdef_no=0, decl_uid=1979, cgraph_uid=1, symbol_order=0)

void f ()
{
   [local count: 1073741824]:
  MEM[(long int *)] = 0;
  return;

}



;; Function g (g, funcdef_no=1, decl_uid=1983, cgraph_uid=2, symbol_order=1)

void g ()
{
   [local count: 1073741824]:
  __atomic_store_8 (, 0, 0); [tail call]
  return;

}

[Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851

2021-09-22 Thread dave.anglin at bell dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #3 from dave.anglin at bell dot net ---
This occurs in stage3, so it's probably an optimization bug.

[Bug c++/100493] Lambda default copy capture that captures "this" cannot be used in both C++17 and C++20 modes

2021-09-22 Thread redbeard0531 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100493

--- Comment #3 from Mathias Stearn  ---
When reading https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82611, I noticed that
C++17 actually requires the warning on [=, this] from a conforming
implementation:
https://timsong-cpp.github.io/cppwp/n4659/expr.prim.lambda.capture#2. However,
given that this requirement was lifted in C++20, would it be possible to only
warn about that in -std=c++17 (or lower) with -pedantic? It seems
counterproductive to warn about it without -pedantic.

[Bug c++/100493] Lambda default copy capture that captures "this" cannot be used in both C++17 and C++20 modes

2021-09-22 Thread redbeard0531 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100493

Mathias Stearn  changed:

   What|Removed |Added

 CC||redbeard0531 at gmail dot com

--- Comment #2 from Mathias Stearn  ---
This is making it harder for us to transition to -std=c++20, since we can't
have the same code be warning-clean in both versions. I really don't think the
warning for [=, this] is helpful given that it is the pattern that is now
recommended.

[Bug rtl-optimization/102356] [11/12 Regression] compile-time explosion at -O3 -g in var-tracking since r11-209-g74dc179a6da33cd0

2021-09-22 Thread vmakarov at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102356

--- Comment #3 from Vladimir Makarov  ---
(In reply to Martin Liška from comment #2)
> If I see correctly, it started with r11-209-g74dc179a6da33cd0.

Yes, I am confirming that my patch triggered the slow down.  But the actual
problem is not RA, it is in scalability of var-tracking pass.

I'll investigate more can I fix it in RA and is it worth to fix it in RA.

[Bug rtl-optimization/102062] powerpc suboptimal unrolling simple array sum

2021-09-22 Thread npiggin at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102062

Nicholas Piggin  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|NEW |RESOLVED

--- Comment #16 from Nicholas Piggin  ---
gcc-11 -O2 -mcpu=power10 now generates identical code that Bill listed for
trunk:

.L2:
lwz 4,4(9)
lwz 5,12(9)
lwz 6,8(9)
lwzu 8,16(9)
add 10,4,10
add 10,10,5
add 7,6,7
add 7,7,8
bdnz .L2

Thanks all.

[Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851

2021-09-22 Thread dave.anglin at bell dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

--- Comment #2 from dave.anglin at bell dot net ---
On 2021-09-22 9:14 a.m., rguenth at gcc dot gnu.org wrote:
> what's MAX_BITSIZE_MODE_ANY_INT in insn-modes.h?  (in the build directory)
> I think it should correspond to TImode and thus be 16 * BITS_PER_UNIT which
> means that we're building an INTEGER_TYPE bigger than TImode - can you confirm
> that?
#define BITS_PER_UNIT (8)
#define MAX_BITSIZE_MODE_ANY_INT (16*BITS_PER_UNIT)
#define MAX_BITSIZE_MODE_ANY_MODE (32*BITS_PER_UNIT)

However, TImode is not supported on this target.

(gdb) ignor 1 325
Will ignore next 325 crossings of breakpoint 1.
(gdb) r
Starting program: /home/dave/gnu/gcc/objdir/gcc/gnat1 -quiet -nostdinc -O2
-Wext  
ra -Wall -dumpbase s-regpat.adb -dumpbase-ext .adb -gnatwa -fchecking=1 -g
-fPIC   
-gnatpg -gnatO s-regpat.o s-regpat.adb -o s-regpat.s

Breakpoint 1, _Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop
    (type=, precision=256, sgn=UNSIGNED)
    at ../../gcc/gcc/stor-layout.c:2851
2851  gcc_assert (precision <= WIDE_INT_MAX_PRECISION);
(gdb) p precision
$2 = 256
(gdb) disass $pc-16,$pc+16
Dump of assembler code from 0xfbc244 to 0xfbc264:
   0x00fbc244
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+36>: stw
r7,-70(sp)
   0x00fbc248
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+40>: stw
r6,-6c(sp)
   0x00fbc24c
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+44>:
cmpib,>= 0,r25,0xfbc2d4
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+180>
   0x00fbc250
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+48>: copy
r26,r3
=> 0x00fbc254
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+52>: ldi
c0,ret0
   0x00fbc258
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+56>:
cmpb,< ret0,r25,0xfbc2fc
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+220>
   0x00fbc25c
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+60>: copy
r24,r25
   0x00fbc260
<_Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop+64>: ldo
-98(sp),r6
End of assembler dump.
(gdb) p $ret0
$3 = 8388608
(gdb) p 0xc0
$4 = 192
(gdb) p $r25
$5 = 256
(gdb) bt
#0  _Z40set_min_and_max_values_for_integral_typeP9tree_nodei6signop (
    type=, precision=256, sgn=UNSIGNED)
    at ../../gcc/gcc/stor-layout.c:2851
#1  0x00fc0b9c in _Z18make_unsigned_typei (precision=256)
    at ../../gcc/gcc/stor-layout.c:2885
#2  0x000da2b4 in _Z18gnat_type_for_sizeji (precision=256, unsignedp=256)
    at ../../gcc/gcc/ada/gcc-interface/utils.c:3670
#3  0x00b05c2c in gimple_fold_builtin_memory_op(gimple_stmt_iterator*,
tree_node*, tree_node*, built_in_function) (v=@0x79aebb68, reserve=256,
exact=true)
    at ../../gcc/gcc/gimple-fold.c:1004
#4  0x00afffac in _ZL11fold_stmt_1P20gimple_stmt_iteratorbPFP9tree_nodeS2_E (
    gsi=0x7a001018, inplace=true, valueize=0x79ae8b58)
    at ../../gcc/gcc/gimple-fold.c:5054
#5  0x00b13668 in _ZL10lower_stmtP20gimple_stmt_iteratorP10lower_data (
    gsi=..., data=0x7a000fa4) at ../../gcc/gcc/gimple-low.c:390
#6  0x00b1405c in _ZL17lower_gimple_bindP20gimple_stmt_iteratorP10lower_data (
    gsi=0x7a000f98, data=0x7a000fa4) at ../../gcc/gcc/gimple-low.c:217
#7  0x00b146a0 in _ZN12_GLOBAL__N_113pass_lower_cf7executeEP8function (
    this=0x79ab92a0) at ../../gcc/gcc/gimple-low.c:110
#8  0x00e8b140 in _Z16execute_one_passP8opt_pass (pass=0x40716078)
    at ../../gcc/gcc/passes.c:2567
#9  0x00e8ba2c in _ZL19execute_pass_list_1P8opt_pass (pass=0x40716078)
    at ../../gcc/gcc/passes.c:2656
---Type  to continue, or q  to quit---
#10 0x00e8bad0 in _Z17execute_pass_listP8functionP8opt_pass (fn=0x79ab92a0,
    pass=0x100) at ../../gcc/gcc/passes.c:2667
#11 0x00906578 in _ZN11cgraph_node7analyzeEv (this=)
    at ../../gcc/gcc/cgraphunit.c:680
#12 0x009098e0 in _ZL17analyze_functionsb (first_time=148)
    at ../../gcc/gcc/cgraphunit.c:1234
#13 0x0090a6c8 in _ZN12symbol_table25finalize_compilation_unitEv (
    this=0x79c59000) at ../../gcc/gcc/cgraphunit.c:2508
#14 0x00fcd444 in _ZL12compile_filev () at ../../gcc/gcc/toplev.c:483
#15 0x00fd0d5c in _ZN6toplev4mainEiPPc (this=0x7a000a98, argc=0, argv=0x0)
    at ../../gcc/gcc/toplev.c:2233
#16 0x01461b40 in main (argc=20, argv=0x7a0008f4) at ../../gcc/gcc/main.c:39

[Bug c/102452] New: Structs with flexible array members are not optimized on stack

2021-09-22 Thread peter at peterzhu dot ca via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102452

Bug ID: 102452
   Summary: Structs with flexible array members are not optimized
on stack
   Product: gcc
   Version: 9.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: peter at peterzhu dot ca
  Target Milestone: ---

Created attachment 51494
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51494=edit
test.c

Structs with flexible array members are not optimized on the stack. Testing
with the test.c file shown below (which outputs the runtime in seconds), we see
that the compiled program is significantly slower when the struct has a
flexible array member than when it does not. This was tested on GCC 9.3.0 and
10.3.0 on Ubuntu 20.04.

$ gcc -O3 test.c
$ ./a.out
0.302769
$ gcc -O3 -DUSE_FLEX_ARR=1 test.c
$ ./a.out
0.728760

clang does not have this issue.

$ clang -O3 test.c
$ ./a.out
0.312194
$ clang -O3 -DUSE_FLEX_ARR=1 test.c
$ ./a.out
0.301175

This is what test.c looks like:

#include 
#include 
#include 
#include 

struct Test {
long is_a;
union {
struct {
long one;
long two;
long three;
} a;
struct {
int one;
int two;
int three;
int four;
#if USE_FLEX_ARR
char arr[];
#endif
} b;
} as;
};

#define COUNT 1

static inline struct Test make_test_a(struct Test *test)
{
if (test->is_a) {
return *test;
} else {
struct Test ret;
ret.as.a.one = test->as.b.one;
ret.as.a.two = test->as.b.two;
ret.as.a.three = test->as.b.three;
return ret;
}
}

/* This function should be optimized to not allocate struct Test on the stack
 * since it only uses attribute "three". */
static inline long get_three(struct Test *test)
{
return make_test_a(test).as.a.three;
}

int main(int argc, char *argv[])
{
struct timespec start, end;

struct Test *mem = malloc(sizeof(struct Test) * COUNT);
memset(mem, 0, sizeof(struct Test) * COUNT);

clock_gettime(CLOCK_MONOTONIC, );
{
for (int i = 0; i < COUNT; i++) {
long three = get_three([i]);
if (three) {
/* Impossible case. */
printf("what\n");
}
}
}
clock_gettime(CLOCK_MONOTONIC, );

double time = (end.tv_sec - start.tv_sec) + (end.tv_nsec - start.tv_nsec) /
10.0;
printf("%f\n", time);

return 0;
}

[Bug tree-optimization/102451] Suspicious null-pointer dereference in delete_dead_or_redundant_call

2021-09-22 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102451

Richard Biener  changed:

   What|Removed |Added

   Last reconfirmed||2021-09-22
 CC||rguenth at gcc dot gnu.org
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
Version|unknown |12.0

--- Comment #1 from Richard Biener  ---
Confirmed.  Mind fixing it by recording the basic-block index before
removing/replacing?

[Bug ada/102450] GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851

2021-09-22 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

Richard Biener  changed:

   What|Removed |Added

 Status|UNCONFIRMED |WAITING
   Last reconfirmed||2021-09-22
 Ever confirmed|0   |1

--- Comment #1 from Richard Biener  ---
what's MAX_BITSIZE_MODE_ANY_INT in insn-modes.h?  (in the build directory)
I think it should correspond to TImode and thus be 16 * BITS_PER_UNIT which
means that we're building an INTEGER_TYPE bigger than TImode - can you confirm
that?

Unfortunately gnat doesn't provide backtraces, so a backtrace from gdb would
also be nice.

[Bug tree-optimization/102087] [12 Regression] ICE on valid code at -O3 on x86_64-linux-gnu: in determine_exit_conditions, at tree-ssa-loop-manip.c:1049 since r12-3136-g3673dcf6d6baeb67

2021-09-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102087

--- Comment #12 from CVS Commits  ---
The master branch has been updated by Jiu Fu Guo :

https://gcc.gnu.org/g:3087d1b0a2cbe8880ccbbb67744726ff4e5d390e

commit r12-3791-g3087d1b0a2cbe8880ccbbb67744726ff4e5d390e
Author: Jiufu Guo 
Date:   Wed Sep 22 13:20:29 2021 +0800

Set bound/cmp/control for until wrap loop.

In patch r12-3136, niter->control, niter->bound and niter->cmp are
derived from number_of_iterations_lt.  While for 'until wrap condition',
the calculation in number_of_iterations_lt is not align the requirements
on the define of them and requirements in determine_exit_conditions.

This patch calculate niter->control, niter->bound and niter->cmp in
number_of_iterations_until_wrap.

gcc/ChangeLog:

2021-09-22  Jiufu Guo  

PR tree-optimization/102087
* tree-ssa-loop-niter.c (number_of_iterations_until_wrap):
Update bound/cmp/control for niter.

gcc/testsuite/ChangeLog:

2021-09-22  Jiufu Guo  

* gcc.dg/pr102087.c: New test.
PR tree-optimization/102087

[Bug c++/102413] [12 Regression] ICE in cp_lexer_consume_token, at cp/parser.c:1172

2021-09-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102413

--- Comment #1 from Jakub Jelinek  ---
Created attachment 51493
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51493=edit
gcc12-pr102413.patch

Untested fix.

[Bug tree-optimization/102451] New: Suspicious null-pointer dereference in delete_dead_or_redundant_call

2021-09-22 Thread fxue at os dot amperecomputing.com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102451

Bug ID: 102451
   Summary: Suspicious null-pointer dereference in
delete_dead_or_redundant_call
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: fxue at os dot amperecomputing.com
  Target Milestone: ---

In the code snippet:

  if (lhs)
{
   
  if (gsi_replace (gsi, new_stmt, true))
bitmap_set_bit (need_eh_cleanup, gimple_bb (stmt)->index);
}
  else
{
  
  if (gsi_remove (gsi, true))
bitmap_set_bit (need_eh_cleanup, gimple_bb (stmt)->index);
}

It is known that "gsi" points to "stmt", and gsi_replace/gsi_remove will clear
basic block of "stmt". Then bitmap_set_bit will dereference "index" from null
bb.

[Bug tree-optimization/102448] [12 Regression] wrong codegen in gcc in spec2017 since 24f99147b9264f8f7d9cfb2fa6bd431edfa252d2

2021-09-22 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102448

Richard Biener  changed:

   What|Removed |Added

 Target||aarch64
   Target Milestone|--- |12.0

--- Comment #1 from Richard Biener  ---
The rev. in question should only affect alignment info on a SSA name.

[Bug ada/102450] New: GCC error: in set_min_and_max_values_for_integral_type, at stor-layout.c:2851

2021-09-22 Thread danglin at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102450

Bug ID: 102450
   Summary: GCC error: in
set_min_and_max_values_for_integral_type, at
stor-layout.c:2851
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: ada
  Assignee: unassigned at gcc dot gnu.org
  Reporter: danglin at gcc dot gnu.org
  Target Milestone: ---
  Host: hppa*-*-* (32-bit)
Target: hppa*-*-* (32-bit)
 Build: hppa*-*-* (32-bit)

/home/dave/gnu/gcc/objdir/./gcc/xgcc -B/home/dave/gnu/gcc/objdir/./gcc/
-B/opt/g
nu/gcc/gcc-12/hppa2.0w-hp-hpux11.11/bin/
-B/opt/gnu/gcc/gcc-12/hppa2.0w-hp-hpux1
1.11/lib/ -isystem /opt/gnu/gcc/gcc-12/hppa2.0w-hp-hpux11.11/include -isystem
/o
pt/gnu/gcc/gcc-12/hppa2.0w-hp-hpux11.11/sys-include   -fchecking=1 -c -g -O2 
-f
PIC  -W -Wall -gnatpg -nostdinc   s-regpat.adb -o s-regpat.o
during GIMPLE pass: lower
+===GNAT BUG DETECTED==+
| 12.0.0 20210922 (experimental) (hppa2.0w-hp-hpux11.11) GCC error:|
| in set_min_and_max_values_for_integral_type, at stor-layout.c:2851   |
| Error detected around s-regpat.adb:345:4 |
| Compiling s-regpat.adb   |
| Please submit a bug report; see https://gcc.gnu.org/bugs/ .  |
| Use a subject line meaningful to you and us to track the bug.|
| Include the entire contents of this bug box in the report.   |
| Include the exact command that you entered.  |
| Also include sources listed below.   |
+==+

Please include these source files with error report
Note that list may not be accurate in some cases,
so please double check that the problem can still
be reproduced with the set of files listed.
Consider also -gnatd.n switch (see debug.adb).

system.ads
s-regpat.adb
s-regpat.ads
s-io.ads
ada.ads
a-charac.ads
a-chahan.ads
a-unccon.ads
s-exctab.ads
s-stalib.ads
a-except.ads
s-parame.ads
s-traent.ads
s-valint.ads
s-unstyp.ads
s-valuns.ads
s-valueu.ads
s-valuei.ads
s-imgcha.ads
s-secsta.ads
s-stoele.ads
s-imgint.ads
s-imagei.ads


raised TYPES.UNRECOVERABLE_ERROR : comperr.adb:414
make[7]: *** [../gcc-interface/Makefile:300: s-regpat.o] Error 1
make[7]: Leaving directory '/home/dave/gnu/gcc/objdir/gcc/ada/rts'
make[6]: *** [gcc-interface/Makefile:627: gnatlib] Error 2
make[6]: Leaving directory '/home/dave/gnu/gcc/objdir/gcc/ada'
make[5]: *** [gcc-interface/Makefile:662: gnatlib-shared-default] Error 2
make[5]: Leaving directory '/home/dave/gnu/gcc/objdir/gcc/ada'

Also occurs on Linux:
https://buildd.debian.org/status/fetch.php?pkg=gcc-snapshot=hppa=1%3A20210918-1=1632002454=0

[Bug c++/102449] New: template parameter with default argument is used without being verified during explicit specialization

2021-09-22 Thread nickhuang99 at hotmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102449

Bug ID: 102449
   Summary: template parameter with default argument is used
without being verified during explicit specialization
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: nickhuang99 at hotmail dot com
  Target Milestone: ---

The following snippet code should be rejected because "First" should be checked
with its default argument which is "char"

template
void foo(First,T){}
template<>
void foo(int,double){}

[Bug tree-optimization/102448] New: [12 Regression] wrong codegen in gcc in spec2017 since 24f99147b9264f8f7d9cfb2fa6bd431edfa252d2

2021-09-22 Thread tnfchris at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102448

Bug ID: 102448
   Summary: [12 Regression] wrong codegen in gcc in spec2017 since
24f99147b9264f8f7d9cfb2fa6bd431edfa252d2
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Keywords: wrong-code
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: tnfchris at gcc dot gnu.org
CC: rguenth at gcc dot gnu.org
  Target Milestone: ---

Since g:24f99147b9264f8f7d9cfb2fa6bd431edfa252d2 we've been getting a segfault
on gcc in spec2017.

It looks like ira_init has been miscompiled and an additional unconditional
store materialized:

Before:

add x1, x19, #0x4
add x2, x19, #0x14
ldr q0, [x0,#4064]
str q0, [x1],#16


After:

add x19, x19, #0x4
ldr q0, [x0,#4000]
str q0, [x19],#16
str q0, [x19],#16

so it's pushing 16 bytes more into x19 than it did before.

Trying to see if I can reduce a testcase

[Bug middle-end/102415] [12 Regression] ICE in bb_seq_addr, at gimple.h:1786

2021-09-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102415

Jakub Jelinek  changed:

   What|Removed |Added

 Resolution|--- |FIXED
 Status|ASSIGNED|RESOLVED

--- Comment #3 from Jakub Jelinek  ---
Fixed.

[Bug preprocessor/102432] [11/12 Regression] ICE in _cpp_lex_direct with function like macro without arguments within "pragma omp" statement

2021-09-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102432

--- Comment #4 from Jakub Jelinek  ---
Started with r11-4686-g8bd9a00f4349ebcd65223e3dcdfe83867e417287

[Bug rtl-optimization/102446] [9/10/11/12 Regression] wrong code at -O3 on x86_64-linux-gnu

2021-09-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102446

--- Comment #9 from Jakub Jelinek  ---
I think PR23567 is quite different, that was about stores to a place that might
not be writable, this is about making a possibly trapping conditional load
being unconditional.

[Bug rtl-optimization/102446] [9/10/11/12 Regression] wrong code at -O3 on x86_64-linux-gnu

2021-09-22 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102446

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=23567

--- Comment #8 from Andrew Pinski  ---
(In reply to Richard Biener from comment #3)
> I don't see any flags marking it as not trapping?

Related to PR 23567 (which was fixed but maybe not fully).

[Bug rtl-optimization/102446] [9/10/11/12 Regression] wrong code at -O3 on x86_64-linux-gnu

2021-09-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102446

--- Comment #7 from Jakub Jelinek  ---
I mean segfaults at runtime, not ICEs.

[Bug rtl-optimization/102446] [9/10/11/12 Regression] wrong code at -O3 on x86_64-linux-gnu

2021-09-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102446

--- Comment #6 from Jakub Jelinek  ---
int a = 1, c, e, f, *j, k, o, *r = , s;
char b, l;
short d, *g;
unsigned h;
static void m(void);
static inline void n(int);
void p(int *q) {
  while (1) {
if (*q)
  break;
if (*g)
  o = c;
while (l)
  ;
  }
}
void t() {
  for (; s < 8; s++)
m();
}
__attribute__((noinline)) void m() {
  int aa = 0, i = 0;
  for (; i < 3; i++)
if (k < 0)
  aa |= *j;
  if (d)
c = (h + *g + 2) & c;
  n(aa);
}
static inline __attribute__((always_inline)) void n(int ac) {
  char *ad = , u = ac, *v = 
  int ae = *ad = a;
  u && (*v = e > 0);
  *r = c;
  p();
}
int main() {
  t();
  return 0;
}

ICEs already in r105000.

[Bug preprocessor/82469] ICE in _cpp_process_line_notes, at libcpp/lex.c:1066

2021-09-22 Thread heiko at hexco dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82469

--- Comment #2 from Heiko Eißfeldt  ---
I took me a while to find a platform of mine where I got this error.

Right now it happens here as well:

Message:
cpp --traditional -ffreestanding -P gcc_82469.c 
: internal compiler error: in _cpp_process_line_notes, at
libcpp/lex.c:1163

OS:
Raspberry Pi, 32-Bit, Linux

uname -a
Linux raspberrypi 5.10.17-v7l+ #1421 SMP Thu May 27 14:00:13 BST 2021 armv7l
GNU/Linux

file /usr/bin/arm-linux-gnueabihf-cpp-8:
/usr/bin/arm-linux-gnueabihf-cpp-8: ELF 32-bit LSB executable, ARM, EABI5
version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for
GNU/Linux 3.2.0, BuildID[sha1]=f4424fc857eedcaef7da81cf953c3ae2788523e7,
stripped

gcc --version
gcc (Raspbian 8.3.0-6+rpi1) 8.3.0

cpp --version
cpp (Raspbian 8.3.0-6+rpi1) 8.3.0

Hardware is a Raspberry Pi Model 4 with 4GB.

Thanks.

[Bug rtl-optimization/102446] [9/10/11/12 Regression] wrong code at -O3 on x86_64-linux-gnu

2021-09-22 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102446

--- Comment #5 from Richard Biener  ---
(In reply to Jan Hubicka from comment #4)
> > Started with r5-6477-g3620b606822f80863488ca4883542d848d41f9f9
> This only affects early inlining decisions, so it may be useful to
> bisect this with --param early-inlining-insns=14
> 
> Honza

It's also miscompiled with -fno-inline.

[Bug rtl-optimization/102446] [9/10/11/12 Regression] wrong code at -O3 on x86_64-linux-gnu

2021-09-22 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102446

Richard Biener  changed:

   What|Removed |Added

   Priority|P3  |P2
  Component|tree-optimization   |rtl-optimization

[Bug tree-optimization/102446] [9/10/11/12 Regression] wrong code at -O3 on x86_64-linux-gnu

2021-09-22 Thread hubicka at ucw dot cz via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102446

--- Comment #4 from Jan Hubicka  ---
> Started with r5-6477-g3620b606822f80863488ca4883542d848d41f9f9
This only affects early inlining decisions, so it may be useful to
bisect this with --param early-inlining-insns=14

Honza

Re: [Bug tree-optimization/102446] [9/10/11/12 Regression] wrong code at -O3 on x86_64-linux-gnu

2021-09-22 Thread Jan Hubicka
> Started with r5-6477-g3620b606822f80863488ca4883542d848d41f9f9
This only affects early inlining decisions, so it may be useful to
bisect this with --param early-inlining-insns=14

Honza


[Bug tree-optimization/102446] [9/10/11/12 Regression] wrong code at -O3 on x86_64-linux-gnu

2021-09-22 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102446

--- Comment #3 from Richard Biener  ---
void m() {
  int aa = 0, i = 0;
  for (; i < 3; i++)
if (k < 0)
  aa |= *j;

Dump of assembler code for function m:
   0x00400540 <+0>: mov0x200b16(%rip),%edi# 0x60105c

   0x00400546 <+6>: mov0x200b13(%rip),%rax# 0x601060

   0x0040054d <+13>:sar$0x1f,%edi
=> 0x00400550 <+16>:and(%rax),%edi
   0x00400552 <+18>:cmpw   $0x0,0x200af6(%rip)# 0x601050


so we're loading *j before checking k < 0.  On GIMPLE that's OK:

   [local count: 268435456]:
  k.5_1 = k;
  j.6_2 = j;
  if (k.5_1 < 0)
goto ; [41.00%]
  else
goto ; [59.00%]

   [local count: 110058537]:
  j.6__lsm0.31_28 = *j.6_2;

   [local count: 268435456]:
  # aa_9 = PHI 

but RTL if-conversion makes the load unconditional.

(insn 13 12 35 3 (set (reg/v:SI 89 [ j.6__lsm0.31 ])
(mem:SI (reg/f:DI 83 [ j.6_2 ]) [1 *j.6_2+0 S4 A32])) 77
{*movsi_internal}
 (expr_list:REG_DEAD (reg/f:DI 83 [ j.6_2 ])
(nil)))

I don't see any flags marking it as not trapping?

[Bug tree-optimization/102446] [9/10/11/12 Regression] wrong code at -O3 on x86_64-linux-gnu

2021-09-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102446

Jakub Jelinek  changed:

   What|Removed |Added

 CC||jakub at gcc dot gnu.org
Summary|wrong code at -O3 on|[9/10/11/12 Regression]
   |x86_64-linux-gnu|wrong code at -O3 on
   ||x86_64-linux-gnu
   Target Milestone|--- |9.5

--- Comment #2 from Jakub Jelinek  ---
Started with r5-6477-g3620b606822f80863488ca4883542d848d41f9f9

[Bug tree-optimization/102446] wrong code at -O3 on x86_64-linux-gnu

2021-09-22 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102446

Richard Biener  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Last reconfirmed||2021-09-22
   Keywords||wrong-code
Version|unknown |12.0
 Status|UNCONFIRMED |NEW

--- Comment #1 from Richard Biener  ---
Confirmed.  Happens with -O3 -fno-inline as well, -fdisable-tree-cunroll "fixes
it", not further investigated.

[Bug target/102222] ICE on s390 (internal compiler error: in extract_insn, at recog.c:2770)

2021-09-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10

--- Comment #8 from CVS Commits  ---
The releases/gcc-11 branch has been updated by Andreas Krebbel
:

https://gcc.gnu.org/g:22b25535b8b2f9961e4772b1cc7cce5dc2f60719

commit r11-9025-g22b25535b8b2f9961e4772b1cc7cce5dc2f60719
Author: Andreas Krebbel 
Date:   Wed Sep 22 09:32:21 2021 +0200

IBM Z: Fix PR10

Avoid emitting a strict low part move if the insv target actually
affects the whole target reg.

gcc/ChangeLog:

PR target/10
* config/s390/s390.c (s390_expand_insv): Emit a normal move if it
is actually a full copy of the source operand into the target.
Don't emit a strict low part move if source and target mode match.

gcc/testsuite/ChangeLog:

* gcc.target/s390/pr10.c: New test.

(cherry picked from commit a9b3c451be58f0fe660154323ace7ba72a4211ec)

[Bug libstdc++/84110] Null character in regex throws std::regex_error

2021-09-22 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84110

Jonathan Wakely  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2021-09-22

[Bug libstdc++/102447] New: std::regex incorrectly accepts invalid bracket expression

2021-09-22 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102447

Bug ID: 102447
   Summary: std::regex incorrectly accepts invalid bracket
expression
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: redi at gcc dot gnu.org
Blocks: 102445
  Target Milestone: ---

#include 
#include 

int main()
{
  try {
std::regex{"[\\w-a]"};
assert(!"here");
  } catch (const std::regex_error& e) {
assert(e.code() == std::regex_constants::error_range);
  }
}

This should run and exit successfully, but with GCC we get:

a.out: reg.C:8: int main(): Assertion `!"here"' failed.
Aborted (core dumped)


The bracket expression [\w-a] is invalid.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102445
[Bug 102445] [meta-bug] std::regex issues

[Bug c++/96593] No "declaration changes meaning" diagnostic for alias templates

2021-09-22 Thread gonzalo.gadeschi at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96593

--- Comment #3 from gnzlbg  ---
>From 102444 (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102444):

See http://eel.is/c++draft/class.member.lookup#6

  [class.member.lookup]/p6: "If it [the result of the search] differs from the
result of a search in T for N from immediately after the class-specifier of T,
the program is ill-formed, no diagnostic required."  A class definition is not
allowed to change the meaning of a name that was already used earlier in the
class definition.

While no diagnostic is required, I think a quality implementation like gcc
should produce a diagnostic here and reject this program since it is
ill-formed.

Example (found in the wild): https://gcc.godbolt.org/z/jhEj68Kq8

struct plus {
  template
  using invoke = void;
};

template 
using invoke = typename Fn::template invoke;

template 
struct compose
{
  template 
  using F = invoke;

  template 
  using invoke = invoke;
};

using Q = compose::F;

Is accepted by gcc.

[Bug c++/96593] No "declaration changes meaning" diagnostic for alias templates

2021-09-22 Thread gonzalo.gadeschi at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96593

gnzlbg  changed:

   What|Removed |Added

 CC||gonzalo.gadeschi at gmail dot 
com

--- Comment #2 from gnzlbg  ---
*** Bug 102444 has been marked as a duplicate of this bug. ***

[Bug c++/102444] class definition not allowed to change meaning of previously used name

2021-09-22 Thread gonzalo.gadeschi at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102444

gnzlbg  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #2 from gnzlbg  ---
I think you are correct, closing this one as duplicate.

Will repost my example there.

*** This bug has been marked as a duplicate of bug 96593 ***

[Bug libstdc++/102445] [meta-bug] std::regex issues

2021-09-22 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102445

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
   Last reconfirmed||2021-09-22

[Bug libstdc++/77744] Data race on std::regex_iterator using openmp

2021-09-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77744

--- Comment #7 from Jakub Jelinek  ---
(In reply to Jonathan Wakely from comment #3)
> More importantly, the OpenMP version does not wait for the loop to finish
> (or at least, I see "#pragma omp for nowait" in the GIMPLE dump), so there
> is no happens-before relation between the loop body and the reTest
> destructor.

It does wait, the nowait there is just an optimization to avoid an unnecessary
extra barrier when there is one at the end of the parallel (the inital thread
doesn't continue until all other threads encountered the final barrier).

Current OpenMP (5.0+) allows lambdas, but we don't really know if there is any
race condition, as I said in #c5, tsan doesn't understand the libgomp barriers
and locking which are done using atomics and futexes, so in order to use
-fsanitize=thread together with libgomp the library needs to be built with
--disable-linux-futex, then it uses pthread_* APIs tsan understands.

[Bug libstdc++/86164] std::regex crashes when matching long lines

2021-09-22 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86164

Jonathan Wakely  changed:

   What|Removed |Added

 CC||shaoqin2 at illinois dot edu

--- Comment #10 from Jonathan Wakely  ---
*** Bug 84865 has been marked as a duplicate of this bug. ***

[Bug libstdc++/84865] Regular expression regex_search falls into infinite loop causing segfault on crayxc machines

2021-09-22 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84865

Jonathan Wakely  changed:

   What|Removed |Added

 Status|WAITING |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #12 from Jonathan Wakely  ---
I'm closing this as a dup of one of the existing bugs about stack overflow.

*** This bug has been marked as a duplicate of bug 86164 ***

[Bug tree-optimization/102446] New: wrong code at -O3 on x86_64-linux-gnu

2021-09-22 Thread zhendong.su at inf dot ethz.ch via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102446

Bug ID: 102446
   Summary: wrong code at -O3 on x86_64-linux-gnu
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

This seems to be a long-latent miscompilation, affecting GCC 5.1 and later.

[583] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--prefix=/local/suz-local/software/local/gcc-trunk --enable-languages=c,c++
--disable-werror --enable-multilib --with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210922 (experimental) [master r12-3777-g578b7687338] (GCC)
[584] %
[584] % gcctk -O2 small.c; ./a.out
[585] %
[585] % gcctk -O3 small.c
[586] % ./a.out
Segmentation fault
[587] %
[587] % cat small.c
int a = 1, c, e, f, *j, k, o, *r = , s;
char b, l;
short d, *g;
unsigned h;
static void m(void);
static void n(int);
void p(int *q) {
  while (1) {
if (*q)
  break;
if (*g)
  o = c;
while (l)
  ;
  }
}
void t() {
  for (; s < 8; s++)
m();
}
void m() {
  int aa = 0, i = 0;
  for (; i < 3; i++)
if (k < 0)
  aa |= *j;
  if (d)
c = (h + *g + 2) & c;
  n(aa);
}
void n(int ac) {
  char *ad = , u = ac, *v = 
  int ae = *ad = a;
  u && (*v = e > 0);
  *r = c;
  p();
}
int main() {
  t();
  return 0;
}

  1   2   >