chiark / gitweb /
Ben Hutchings reports that gcc 4 gives an optimiser warning because
authorSimon Tatham <anakin@pobox.com>
Fri, 29 Jul 2005 11:34:02 +0000 (11:34 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 29 Jul 2005 11:34:02 +0000 (11:34 +0000)
it can't tell that one branch of a particular switch is always
taken. Adding a default clause with an automatic assertion failure
apparently fixes it.

[originally from svn r6148]

rect.c

diff --git a/rect.c b/rect.c
index a7113afc36cea1167cc0dad18b292ef3d6769967..439ae1f3aec4ea967112bc2d9cf15acaab0abd71 100644 (file)
--- a/rect.c
+++ b/rect.c
@@ -1348,6 +1348,8 @@ static char *new_game_desc(game_params *params, random_state *rs,
                                 r1.x++;
                             r1.w--;
                             break;
+                          default:     /* should never happen */
+                            assert(!"invalid direction");
                         }
                         if (r1.h > 0 && r1.w > 0)
                             place_rect(params2, grid, r1);