Skip to content

Commit

Permalink
Work around the GCC enum bound check bug more effectively
Browse files Browse the repository at this point in the history
  • Loading branch information
lethosor committed Jul 18, 2015
1 parent a56692a commit ce779e7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Enum.pm
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,9 @@ sub render_enum_tables($$$$) {
emit "static const base_type last_item_value = ", ($base+$count-1), ";";
emit_block {
# Cast the enum to integer in order to avoid GCC assuming the value range is correct.
emit "return (base_type(value) >= first_item_value && ",
"base_type(value) <= last_item_value);";
emit "volatile base_type *value2 = (base_type*)&value;";
emit "return (base_type(*value2) >= base_type(first_item_value) && ",
"base_type(*value2) <= base_type(last_item_value));";
} "static inline bool is_valid(enum_type value) ";
emit "static const enum_type first_item = (enum_type)first_item_value;";
emit "static const enum_type last_item = (enum_type)last_item_value;";
Expand Down

3 comments on commit ce779e7

@jeturcotte
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies; I'm still very interested in getting armok vision to work for me, so I thought I'd apply this change and take my chances... but this perl module is not present in my (current version) installation of df-hack. A fresh download of both the source code and the -r3 OSX package, thus far, APPEAR to lack the above. Interestingly (if unrelated), it DOES contain .xml for dealing with the graphics my wife (kafine) made (hah!) I'm still poking around, trying to connect the dots, but I thought I'd ask directly how I'm expected to apply this and try again.

@lethosor
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the plugin I put up not work?
Anyway, this file is only used at compile time to generate headers for DF enums. It's in the library/xml submodule, so if you used the "download zip" button instead of using git to clone the repository you'll have an empty folder there.

@jeturcotte
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, dangit... my bad. I'd pulled a fresh 0.5 and plugin, and they didn't work at the time. I must have done something incorrect, as trying again now... works! Sorry again, and thanks!

Please sign in to comment.