This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/34656] modifies do loop variable
- From: "jv244 at cam dot ac dot uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Jan 2008 07:02:37 -0000
- Subject: [Bug fortran/34656] modifies do loop variable
- References: <bug-34656-6642@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from jv244 at cam dot ac dot uk 2008-01-04 07:02 -------
(In reply to comment #1)
> This is almost impossible to diagnose. Do you know of any compiler that
> detects this?
I think that lahey detects this at runtime. Almost all compilers detect the
simple case of directly (i.e. not through a call) modifing the variable. I
think it is actually a rather useful warning/error since it is an easy mistake
to make.
>
> The only way I see to diagnose this, is to mark all do loop variables as such,
> and warn about all assignments to such variables in contained functions.
> which also seems undesirable... Thoughts?
>
I don't think this would be good enough without the extra check that this
contained function is called from within the corresponding loop. In principle
all information is available in this case, but I guess it might be difficult to
extract.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34656