Bug 57791 - Wasted work in gfc_check_pointer_assign()
Summary: Wasted work in gfc_check_pointer_assign()
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2013-07-02 20:32 UTC by Po-Chun Chang
Modified: 2013-07-29 19:09 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Suggested patch (276 bytes, patch)
2013-07-02 20:32 UTC, Po-Chun Chang
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Po-Chun Chang 2013-07-02 20:32:19 UTC
Created attachment 30430 [details]
Suggested patch

The problem appears in revision 200588 in version 4.9. I have attached a one-line patch that fixes it.

In method "gfc_check_pointer_assign()" in expr.c, the loop on line 3763 should break immediately after "warn" is set to "true". All the iterations after "warn" set to "true" do not perform any useful work, at best they just set "warn" again to "true".
Comment 1 Tobias Burnus 2013-07-03 06:56:51 UTC
(In reply to Po-Chun Chang from comment #0)
> Suggested patch
> 
> In method "gfc_check_pointer_assign()" in expr.c, the loop on line 3763
> should break immediately after "warn" is set to "true". All the iterations
> after "warn" set to "true" do not perform any useful work, at best they just
> set "warn" again to "true".

I concur.

(Note that the nesting depth is rather shallow [one or two, rarely three and essentially never four or more] and only pointer comparisons are done, which is computationally cheap. Thus, the current version doesn't waste many cycles.)
Comment 2 Po-Chun Chang 2013-07-23 21:43:47 UTC
Patch sent to gcc-patches@ and fortran@

http://gcc.gnu.org/ml/gcc-patches/2013-07/msg01056.html
http://gcc.gnu.org/ml/fortran/2013-07/msg00070.html
Comment 3 Jeffrey A. Law 2013-07-29 19:09:41 UTC
Patch installed on trunk.