Re: [PATCH] Fortran: out of bounds access with nested implied-do IO [PR111837]

2023-10-16 Thread Jerry D

On 10/16/23 12:11 PM, Harald Anlauf wrote:

Dear All,

the attached patch fixes a dependency check in frontend optimzation
for nested implied-do IO.  The problem appeared for >= 3 loops only
as the check considered dependencies to be only of band form instead
of triangular form.

Regtested on x86_64-pc-linux-gnu.  OK for mainline?

As this fixes a regression since 8-release, I plan to backport
to all active branches.

Thanks,
Harald



OK for Mainline and backport

Thanks Harald

Jerry


Re: Compiler for Windows

2023-10-16 Thread Arjen Markus
I use the version of gfortran that can be found at equation.com. There are
several other possibilities, such using the packages found in
MinGW-w64/MSYS2 or Cygwin, but this works fine for me and under plain
Windows (i.e. in an ordinary command window).

Regards,

Arjen

Op ma 16 okt 2023 om 18:08 schreef Tucker, Mark :

> Hi Folks,
>
> Please could you let me know where I can find an installer which would
> install Gfortran onto a Windows machine?  Note that we have Windows Server
> 2019.
>
> Thanks in advance,
>
> Dr MarkTucker  PhD
>
> Manager | Actuarial, Insurance and Banking | Deloitte MCS Limited
> 9 Haymarket Square, Edinburgh, EH3 8RY
>
> marktuc...@deloitte.co.uk | +44 7385 933427
>
>
> IMPORTANT NOTICE
>
> This communication is from Deloitte LLP, a limited liability partnership
> registered in England and Wales with registered number OC303675. Its
> registered office is 1 New Street Square, London EC4A 3HQ, United Kingdom.
> Deloitte LLP is the United Kingdom affiliate of Deloitte NSE LLP, a member
> firm of Deloitte Touche Tohmatsu Limited, a UK private company limited by
> guarantee (“DTTL”). DTTL and each of its member firms are legally separate
> and independent entities. DTTL and Deloitte NSE LLP do not provide services
> to clients. Please see www.deloitte.co.uk/about<
> https://www.deloitte.co.uk/about> to learn more about our global network
> of member firms. For details of our professional regulation please see
> Regulators<
> https://www2.deloitte.com/uk/en/footerlinks1/regulators-and-provision-service-regulations.html
> >.
>
> This communication contains information which is confidential and may also
> be privileged. It is for the exclusive use of the intended recipient(s). If
> you are not the intended recipient(s), please notify
> datasecurityrep...@deloitte.co.uk
> and destroy this message immediately. Email communications cannot be
> guaranteed to be secure or free from error or viruses. All emails sent to
> or from a @deloitte.co.uk email account are securely archived and stored
> by an external supplier within the European Union.
>
> You can understand more about how we collect and use (process) your
> personal information in our Privacy Notice<
> https://www2.deloitte.com/uk/en/legal/privacy.html>.
>
> Deloitte LLP does not accept any liability for use of or reliance on the
> contents of this email by any person save by the intended recipient(s) to
> the extent agreed in a Deloitte LLP engagement contract.
>
> Opinions, conclusions and other information in this email which have not
> been delivered by way of the business of Deloitte LLP are neither given nor
> endorsed by it.
>


[PATCH] Fortran: out of bounds access with nested implied-do IO [PR111837]

2023-10-16 Thread Harald Anlauf
Dear All,

the attached patch fixes a dependency check in frontend optimzation
for nested implied-do IO.  The problem appeared for >= 3 loops only
as the check considered dependencies to be only of band form instead
of triangular form.

Regtested on x86_64-pc-linux-gnu.  OK for mainline?

As this fixes a regression since 8-release, I plan to backport
to all active branches.

Thanks,
Harald

From 43ec8b856a67a1b70744e5c0d50ea7fa2dd9a8ee Mon Sep 17 00:00:00 2001
From: Harald Anlauf 
Date: Mon, 16 Oct 2023 21:02:20 +0200
Subject: [PATCH] Fortran: out of bounds access with nested implied-do IO
 [PR111837]

gcc/fortran/ChangeLog:

	PR fortran/111837
	* frontend-passes.cc (traverse_io_block): Dependency check of loop
	nest shall be triangular, not banded.

gcc/testsuite/ChangeLog:

	PR fortran/111837
	* gfortran.dg/implied_do_io_8.f90: New test.
---
 gcc/fortran/frontend-passes.cc|  2 +-
 gcc/testsuite/gfortran.dg/implied_do_io_8.f90 | 18 ++
 2 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gfortran.dg/implied_do_io_8.f90

diff --git a/gcc/fortran/frontend-passes.cc b/gcc/fortran/frontend-passes.cc
index 136a292807d..536884b13f0 100644
--- a/gcc/fortran/frontend-passes.cc
+++ b/gcc/fortran/frontend-passes.cc
@@ -1326,7 +1326,7 @@ traverse_io_block (gfc_code *code, bool *has_reached, gfc_code *prev)
   if (iters[i])
 	{
 	  gfc_expr *var = iters[i]->var;
-	  for (int j = i - 1; j < i; j++)
+	  for (int j = 0; j < i; j++)
 	{
 	  if (iters[j]
 		  && (var_in_expr (var, iters[j]->start)
diff --git a/gcc/testsuite/gfortran.dg/implied_do_io_8.f90 b/gcc/testsuite/gfortran.dg/implied_do_io_8.f90
new file mode 100644
index 000..c66a0f6fde6
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/implied_do_io_8.f90
@@ -0,0 +1,18 @@
+! { dg-do run }
+! { dg-additional-options "-fcheck=bounds" }
+! PR fortran/111837 - out of bounds access with front-end optimization
+
+program implied_do_bug
+  implicit none
+  integer :: i,j,k
+  real:: arr(1,1,1)
+  integer :: ni(1)
+  ni(1) = 1
+  arr = 1
+  write(*,*) (((arr(i,j,k), i=1,ni(k)), k=1,1), j=1,1)
+  write(*,*) (((arr(i,j,k), i=1,ni(k)), j=1,1), k=1,1)
+  write(*,*) (((arr(k,i,j), i=1,ni(k)), k=1,1), j=1,1)
+  write(*,*) (((arr(k,i,j), i=1,ni(k)), j=1,1), k=1,1)
+  write(*,*) (((arr(j,k,i), i=1,ni(k)), k=1,1), j=1,1)
+  write(*,*) (((arr(j,k,i), i=1,ni(k)), j=1,1), k=1,1)
+end
--
2.35.3



Re: [patch] fortran/intrinsic.texi: Add 'passed by value' to signal handler

2023-10-16 Thread Steve Kargl
On Mon, Oct 16, 2023 at 08:31:20PM +0200, Harald Anlauf wrote:
> 
> Am 16.10.23 um 19:11 schrieb Tobias Burnus:
> > Yesterday, someone was confused because the signal handler did not work.
> > 
> > It turned out that the created Fortran procedure used as handler used
> > pass by reference - and 'signal' passed the it by value.
> > 
> > This patch adds the 'passed by value' to the wording:
> > 
> > "@var{HANDLER} to be executed with a single integer argument passed by
> > value"
> > 
> > OK for mainline?
> 
> I think the patch qualifies as obvious.
> 
> While at it, you might consider removing the comment a few lines below
> the place you are changing,
> 
> @c TODO: What should the interface of the handler be?  Does it take
> arguments?
> 
> and enhance the given example by e.g.:
> 
> subroutine handler_print (signal_number)
>   integer, value :: signal_number
>   print *, "In handler_print: received signal number", signal_number
> end subroutine handler_print
> 

Good suggestion, Harald.  I was composing a similar email
when I saw yours pop into by inbox.

-- 
Steve


Re: [patch] fortran/intrinsic.texi: Add 'passed by value' to signal handler

2023-10-16 Thread Harald Anlauf

Hi Tobias,

Am 16.10.23 um 19:11 schrieb Tobias Burnus:

Yesterday, someone was confused because the signal handler did not work.

It turned out that the created Fortran procedure used as handler used
pass by reference - and 'signal' passed the it by value.

This patch adds the 'passed by value' to the wording:

"@var{HANDLER} to be executed with a single integer argument passed by
value"

OK for mainline?


I think the patch qualifies as obvious.

While at it, you might consider removing the comment a few lines below
the place you are changing,

@c TODO: What should the interface of the handler be?  Does it take
arguments?

and enhance the given example by e.g.:

subroutine handler_print (signal_number)
  integer, value :: signal_number
  print *, "In handler_print: received signal number", signal_number
end subroutine handler_print

Thanks,
Harald


Tobias
-
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201,
80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer:
Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München;
Registergericht München, HRB 106955




[patch] fortran/intrinsic.texi: Add 'passed by value' to signal handler

2023-10-16 Thread Tobias Burnus

Yesterday, someone was confused because the signal handler did not work.

It turned out that the created Fortran procedure used as handler used
pass by reference - and 'signal' passed the it by value.

This patch adds the 'passed by value' to the wording:

"@var{HANDLER} to be executed with a single integer argument passed by
value"

OK for mainline?

Tobias
-
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas 
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht 
München, HRB 106955
fortran/intrinsic.texi: Add 'passed by value' to signal handler

gcc/fortran/ChangeLog:

	* intrinsic.texi (signal): Mention that the argument
	passed to the signal handler procedure is passed by reference.

diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index 6c7ad03a02c..3620209e00a 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -13168,10 +13168,10 @@ end program test_sign
 @table @asis
 @item @emph{Description}:
 @code{SIGNAL(NUMBER, HANDLER [, STATUS])} causes external subroutine
-@var{HANDLER} to be executed with a single integer argument when signal
-@var{NUMBER} occurs.  If @var{HANDLER} is an integer, it can be used to
-turn off handling of signal @var{NUMBER} or revert to its default
-action.  See @code{signal(2)}.
+@var{HANDLER} to be executed with a single integer argument passed by
+value when signal @var{NUMBER} occurs.  If @var{HANDLER} is an integer,
+it can be used to turn off handling of signal @var{NUMBER} or revert to
+its default action.  See @code{signal(2)}.
 
 If @code{SIGNAL} is called as a subroutine and the @var{STATUS} argument
 is supplied, it is set to the value returned by @code{signal(2)}.


Compiler for Windows

2023-10-16 Thread Tucker, Mark
Hi Folks,

Please could you let me know where I can find an installer which would install 
Gfortran onto a Windows machine?  Note that we have Windows Server 2019.

Thanks in advance,

Dr MarkTucker  PhD

Manager | Actuarial, Insurance and Banking | Deloitte MCS Limited
9 Haymarket Square, Edinburgh, EH3 8RY

marktuc...@deloitte.co.uk | +44 7385 933427


IMPORTANT NOTICE

This communication is from Deloitte LLP, a limited liability partnership 
registered in England and Wales with registered number OC303675. Its registered 
office is 1 New Street Square, London EC4A 3HQ, United Kingdom. Deloitte LLP is 
the United Kingdom affiliate of Deloitte NSE LLP, a member firm of Deloitte 
Touche Tohmatsu Limited, a UK private company limited by guarantee (“DTTL”). 
DTTL and each of its member firms are legally separate and independent 
entities. DTTL and Deloitte NSE LLP do not provide services to clients. Please 
see www.deloitte.co.uk/about to learn more 
about our global network of member firms. For details of our professional 
regulation please see 
Regulators.

This communication contains information which is confidential and may also be 
privileged. It is for the exclusive use of the intended recipient(s). If you 
are not the intended recipient(s), please notify 
datasecurityrep...@deloitte.co.uk and 
destroy this message immediately. Email communications cannot be guaranteed to 
be secure or free from error or viruses. All emails sent to or from a 
@deloitte.co.uk email account are securely archived and stored by an external 
supplier within the European Union.

You can understand more about how we collect and use (process) your personal 
information in our Privacy 
Notice.

Deloitte LLP does not accept any liability for use of or reliance on the 
contents of this email by any person save by the intended recipient(s) to the 
extent agreed in a Deloitte LLP engagement contract.

Opinions, conclusions and other information in this email which have not been 
delivered by way of the business of Deloitte LLP are neither given nor endorsed 
by it.