On Tue, Jan 27, 2015 at 09:19:20AM +0300, Yury Gribov wrote: > As described in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64741 , ASan > may currently report false positives for UBSan internal variables due to > their incomplete type information. This patch fixes this. > > Bootstrapped and regtested on Linux x64. Ok to commit? > > -Y
> commit cf083510ece7b7bde1ab5a41e293b5a6a5bb4550 > Author: Yury Gribov <y.gri...@samsung.com> > Date: Mon Jan 26 10:19:03 2015 +0300 > > 2015-01-26 Yury Gribov <y.gri...@samsung.com> > > PR ubsan/64741 > > * ubsan.c (ubsan_type_descriptor): Update type size. No extra newline between PR and * ubsan.c lines. > --- a/gcc/ubsan.c > +++ b/gcc/ubsan.c > @@ -504,6 +504,14 @@ ubsan_type_descriptor (tree type, enum ubsan_print_style > pstyle) > tinfo = get_ubsan_type_info_for_type (type); > > /* Create a new VAR_DECL of type descriptor. */ > + const char *tmp = pp_formatted_text (&pretty_name); > + size_t len = strlen (tmp); > + tree str = build_string (len + 1, tmp); > + TREE_TYPE (str) = build_array_type (char_type_node, > + build_index_type (size_int (len))); > + TREE_READONLY (str) = 1; > + TREE_STATIC (str) = 1; While touching this, could you please rewrite it as: const char *tmp = pp_formatted_text (&pretty_name); size_t len = strlen (tmp) + 1; tree str = build_string (len, tmp); TREE_TYPE (str) = build_array_type_nelts (char_type_node, len); TREE_READONLY (str) = 1; TREE_STATIC (str) = 1; ? Or, if you want, do it as a follow-up. There is another occurrence of this in ubsan_source_location. Ok for trunk with or without this change. Jakub