[PATCH] statistics.c: Fix a potential compiler bug triggered in gcc 3.4.5

Lubomir I. Ivanov neolit123 at gmail.com
Sat Feb 23 08:05:22 PST 2013


From: "Lubomir I. Ivanov" <neolit123 at gmail.com>

This may look as a simple formatting change and won't make much sense
to the C programmer, but it is an actual bug fix in Subsurface for the
target compiler, since it introduces bogus instructions.

The "month" variable ends up being incremented up to 72 for a single
"month++" call (if inside offset brackets).

Better explained here:
http://lists.hohndel.org/pipermail/subsurface/2013-February/003967.html

Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
---

please mind that i'm perfectly ok with this not being included, still i think
it should be or at least i would include fixes like that. my reasoning is that
if someone decides to use said compiler (which is unlikely) and statistics.c
haven't changed much he will definitelly encounter that bug and i will then
have to waste time explaining the issue again.

the obvious fix is to send patch to the gcc folks, but i hardly believe anyone
maintains this 6y/o version anymore.

again, if the patch is NACK-ed, i will probably just write a SED script
for my own needs and i'm good to go. :)

---
 statistics.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/statistics.c b/statistics.c
index 73c7718..b552580 100644
--- a/statistics.c
+++ b/statistics.c
@@ -361,7 +361,8 @@ static void update_yearly_stats()
 
 		for (j = 0; combined_months < stats_yearly[i].selection_size; ++j) {
 			combined_months += stats_monthly[month].selection_size;
-			process_interval_stats(stats_monthly[month++], &year_iter, &month_iter);
+			process_interval_stats(stats_monthly[month], &year_iter, &month_iter);
+			month++;
 		}
 	}
 }
-- 
1.7.11.msysgit.0



More information about the subsurface mailing list