[vlc-devel] [PATCH] m4/stdcxx_11: enable compilation with GCC 4.8.x

Filip Roséen filip at atch.se
Tue Feb 7 14:07:06 CET 2017


Hi Jan,

This message is somewhat of a copy+paste of what I wrote in
`#videolan` @ `freenode`, as I believe it is better to propagate my
opinions raised there to the *mailing-list*.

The problem that your patch address was mentioned by *Sean McGovern*
back in September last year:

 - https://mailman.videolan.org/pipermail/vlc-devel/2016-September/109451.html

On 2017-02-07 02:39, Jan Ekström wrote:

> The tested functionality is not utilized in actual VLC code, and
> it exists in GCC 4.8.x, albeit under an incorrect name. 4.8.x is
> still utilized in LTS systems, such as Ubuntu 14.04.
> ---
>  m4/stdcxx_11.m4 | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)

Effectively circumventing this check will only postpone the problem
until some module that expect a confirming `c++11` implementation will
refers to `max_align_t` as with its *qualified-id*.

In order to make this patch more complete, a *fixup* for `gcc 4.8.4`
which injects `max_align_t` into `namespace std` would be necessary.

I understand that it is tempting to circumvent the check as there are
no modules within the codebase that currently refers to
`std::max_align_t`; but allowing a non-confirming compiler to pass the
test means that we end up in a scenario where we have to decide where
the line should be drawn for other compilers that might "benefit" from
the same treatment.

> diff --git a/m4/stdcxx_11.m4 b/m4/stdcxx_11.m4
> index 59df0a0..0c515ae 100644
> --- a/m4/stdcxx_11.m4
> +++ b/m4/stdcxx_11.m4
> @@ -87,10 +87,20 @@ m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[
>      #include <climits>
>      #include <cstddef>
>  
> +    #define MAX_ALIGN std::max_align_t
> +
> +    #if defined(__GNUC__) && defined(__GNUC_MINOR__) && !defined(__clang__)
> +    #define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
> +    #if GCC_VERSION <= 408
> +    #undef MAX_ALIGN
> +    #define MAX_ALIGN ::max_align_t
> +    #endif
> +    #endif
> +
>      constexpr uint64_t constant_u64 = UINT64_C(0x100000000);
>      constexpr unsigned constant_lim = UINT_MAX;
>      const char *constant_fmt = "%" PRIu64, *constant_scn = "%" SCNu64;
> -    constexpr size_t constant_align = alignof (std::max_align_t);
> +    constexpr size_t constant_align = alignof (MAX_ALIGN);

The above check can be simplified by making use of `using namespace
std`, and then refer to `max_align_t` as an *unqualified-id* (given
that the name either lives in the global namespace, or under
`namespace std`).

>  ]])
>  
>  AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
> -- 
> 2.9.3

`gcc 4.8.4` is a weird beast as there are **very** minor
non-confirming entities within it; so I definitely see why you would
like things to build without having to do manual labor.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20170207/02e7aa83/attachment.html>


More information about the vlc-devel mailing list