- BugFix: GCC allows arithmetic on function pointers
[cparser] / ast2firm.c
index 6735e32..09f48fd 100644 (file)
@@ -2151,8 +2151,10 @@ static ir_node *adjust_for_pointer_arithmetic(dbg_info *dbgi,
        type_t         *const points_to    = skip_typeref(pointer_type->points_to);
        unsigned              elem_size    = get_type_size_const(points_to);
 
-       /* gcc extension */
-       if (elem_size == 0 && is_type_atomic(points_to, ATOMIC_TYPE_VOID)) {
+       /* gcc extension: allow arithmetic with void * and function * */
+       if (elem_size == 0 &&
+           (is_type_atomic(points_to, ATOMIC_TYPE_VOID) ||
+            is_type_function(points_to)))  {
                elem_size = 1;
        }