While following GCC's handling of 'volatile' and other type qualifiers, I noticed that the gimplify pass created temporaries with a type with 'volatile' asserted if the underlying type also had 'volatile' asserted.
Temporaries are created by the create_tmp_var_raw() procedure in gimplify.c, which reads as follows: tree create_tmp_var_raw (tree type, const char *prefix) { tree tmp_var; tree new_type; /* Make the type of the variable writable. */ new_type = build_type_variant (type, 0, 0); TYPE_ATTRIBUTES (new_type) = TYPE_ATTRIBUTES (type); tmp_var = build_decl (VAR_DECL, prefix ? create_tmp_var_name (prefix) : NULL, type); [...] Note above that an unqualified type, new_type, is created but then subsequently not used in the call to build_decl. Because of this omission, if 'type' originally had any qualifiers set (such as volatile), they'll be propagated to the temporary, which might have some unexpected effects on subsequent optimizations and code generation. The fix, I think, is to pass 'new_type': Index: gimplify.c =================================================================== --- gimplify.c (revision 113552) +++ gimplify.c (working copy) @@ -449,7 +449,7 @@ TYPE_ATTRIBUTES (new_type) = TYPE_ATTRIBUTES (type); tmp_var = build_decl (VAR_DECL, prefix ? create_tmp_var_name (prefix) : NULL, - type); + new_type); /* The variable was declared by the compiler. */ DECL_ARTIFICIAL (tmp_var) = 1; (If this analysis is correct and it is recommended that I file a bug report on this, or post a patch, please let me know.)