[Libosinfo] [PATCH] Disable -Wunsafe-loop-optimizations warnings

Fabiano Fidêncio fabiano at fidencio.org
Fri Feb 24 09:18:50 UTC 2017


On Wed, Feb 22, 2017 at 6:33 PM, Daniel P. Berrange <berrange at redhat.com> wrote:
> This warning option is not reporting broken code. Rather it is merely
> identifying loops which GCC would not be able to optimize fully when
> using -funsafe-loop-optimizations.  In GCC 7 this triggers on the
> loader code
>
> osinfo_loader.c: In function 'osinfo_loader_process_list':
> osinfo_loader.c:2127:11: error: missed loop optimization, the loop counter may overflow [-Werror=unsafe-loop-optimizations]
>      while (tmp && *tmp) {
>            ^
>
> The warning just needs to be turned off since the code is not broken,
> and we don't care about the optimization level
>
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
>
> Pushed as a broken build fix for Fedora rawhide
>
>  m4/libosinfo-compile-warnings.m4 | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/m4/libosinfo-compile-warnings.m4 b/m4/libosinfo-compile-warnings.m4
> index 9e0469a..1876837 100644
> --- a/m4/libosinfo-compile-warnings.m4
> +++ b/m4/libosinfo-compile-warnings.m4
> @@ -41,6 +41,10 @@ AC_DEFUN([LIBOSINFO_COMPILE_WARNINGS],[
>      dontwarn="$dontwarn -Wlong-long"
>      # Unused macros are ok
>      dontwarn="$dontwarn -Wunused-macros"
> +    # This isn't warning about code bugs, it is telling
> +    # you about loops which the compiler can't optimize
> +    # due to unpredictable boundary conditions
> +    dontwarn="$dontwarn -Wunsafe-loop-optimizations"
>
>
>      # g_clear_object & G_ATOMIC_OP_USE_GCC_BUILTINS causes
> --
> 2.9.3
>
> _______________________________________________
> Libosinfo mailing list
> Libosinfo at redhat.com
> https://www.redhat.com/mailman/listinfo/libosinfo

Acked-by: Fabiano Fidêncio <fabiano at fidencio.org>

-- 
Fabiano Fidêncio




More information about the Libosinfo mailing list