[Bug lto/79062] -Walloca-larger-than and -Wformat-overflow warnings disabled by -flto
bernd.edlinger at hotmail dot de
gcc-bugzilla@gcc.gnu.org
Sat Apr 22 08:24:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79062
Bernd Edlinger <bernd.edlinger at hotmail dot de> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bernd.edlinger at hotmail dot de
--- Comment #5 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
(In reply to Martin Sebor from comment #3)
> The following allows the format string to be recognized even with LTO. The
> sprintf pass runs and seems to work correctly, but warnings from it for some
> reason do not appear on output. It's as if they were disabled. I'm not
> sure what's causing that.
>
> diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
> index 85f97b2..687a87f 100644
> --- a/gcc/gimple-ssa-sprintf.c
> +++ b/gcc/gimple-ssa-sprintf.c
> @@ -373,7 +373,16 @@ get_format_string (tree format, location_t *ploc)
> if (TREE_CODE (format) != STRING_CST)
> return NULL;
>
> - if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (format))) != char_type_node)
> + tree type = TREE_TYPE (format);
> + if (TREE_CODE (type) == ARRAY_TYPE)
> + type = TREE_TYPE (type);
> +
> + /* Can't just test that:
> + TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (format))) != char_type_node
> + See bug 79062. */
> + if (TREE_CODE (type) != INTEGER_TYPE
> + || TYPE_MODE (type) != TYPE_MODE (char_type_node)
> + || TYPE_PRECISION (type) != TYPE_PRECISION (char_type_node))
> {
> /* Wide format string. */
> return NULL;
That looks wrong.
Does that mean that LTO creates a different char type,
i.e. other than char_type_node, signed_char_type_node
and unsigned_char_type_node ?
I think that would also break the TBAA machinery:
alias_set_type
gimple_get_alias_set (tree t)
{
/* That's all the expressions we handle specially. */
if (!TYPE_P (t))
return -1;
/* For convenience, follow the C standard when dealing with
character types. Any object may be accessed via an lvalue that
has character type. */
if (t == char_type_node
|| t == signed_char_type_node
|| t == unsigned_char_type_node)
return 0;
which is used in LTO and relies on the same.
More information about the Gcc-bugs
mailing list