Jakub Jelinek <ja...@redhat.com> writes:
> On Sun, Oct 15, 2023 at 12:43:10PM +0100, Richard Sandiford wrote:
>> It seemed like there was considerable support for bumping the minimum
>> to beyond 4.8.  I think we should wait until a decision has been made
>> before adding more 4.8 workarounds.
>
> I think adding a workaround until that decision is made and perhaps
> removing it afterwards will make life easier for people still using gcc 4.8.
>
>> Having a conditional explicit constructor is dangerous because it changes
>> semantics.  E.g. consider:
>> 
>>   #include <new>
>> 
>>   union u { int x; };
>>   void f(u *ptr) { new(ptr) u; }
>>   void g(u *ptr) { new(ptr) u(); }
>> 
>> g(ptr) zeros ptr->x whereas f(ptr) doesn't.  If we add "u() {}" then g()
>> does not zero ptr->x.
>> 
>> So if we did add the workaround, it would need to be unconditional,
>> like you say.
>
> What about using more directed workaround then?
>
> Like (just stage1 build tested, perhaps with comment why we do that)
> below?  Seems at least in stage1 it is the only problematic spot.
>
> --- a/gcc/cse.cc
> +++ b/gcc/cse.cc
> @@ -4951,8 +4951,14 @@ cse_insn (rtx_insn *insn)
>           && is_a <scalar_int_mode> (mode, &int_mode)
>           && (extend_op = load_extend_op (int_mode)) != UNKNOWN)
>         {
> +#if GCC_VERSION >= 5000
>           struct rtx_def memory_extend_buf;
>           rtx memory_extend_rtx = &memory_extend_buf;
> +#else
> +         alignas (alignof (rtx_def)) unsigned char
> +           memory_extended_buf[sizeof (rtx_def)];

Looks like the simpler "alignas (rtx_def)" should work.

LGTM otherwise FWIW.

Richard

> +         rtx memory_extend_rtx = (rtx) &memory_extended_buf[0];
> +#endif
>  
>           /* Set what we are trying to extend and the operation it might
>              have been extended with.  */
>
>
>       Jakub

Reply via email to