RFA (libstdc++): PATCH to implement C++17 over-aligned new
Jason Merrill
jason@redhat.com
Mon Sep 12 20:58:00 GMT 2016
I'm checking in this patch, which should fix the remaining issues:
On Sat, Sep 10, 2016 at 2:14 PM, Andreas Schwab <schwab@linux-m68k.org> wrote:
> FAIL: g++.dg/cpp1z/aligned-new1.C (test for excess errors)
> Excess errors:
> /daten/aranym/gcc/gcc-20160910/gcc/testsuite/g++.dg/cpp1z/aligned-new1.C:10:20: warning: requested alignment 64 is larger than 16 [-Wattributes]
> FAIL: g++.dg/cpp1z/aligned-new1.C execution test
> FAIL: g++.dg/cpp1z/aligned-new4.C (test for warnings, line 11)
> FAIL: g++.dg/cpp1z/aligned-new4.C (test for excess errors)
> Excess errors:
> /daten/aranym/gcc/gcc-20160910/gcc/testsuite/g++.dg/cpp1z/aligned-new4.C:3:20: warning: requested alignment 64 is larger than 16 [-Wattributes]
> /daten/aranym/gcc/gcc-20160910/gcc/testsuite/g++.dg/cpp1z/aligned-new4.C:4:20: warning: requested alignment 64 is larger than 16 [-Wattributes]
> FAIL: g++.dg/cpp1z/aligned-new5.C -std=gnu++11 (test for excess errors)
> Excess errors:
> aligned-new5.C:(.text+0xe): undefined reference to `operator new(unsigned int, std::align_val_t)'
>
> Andreas.
>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
-------------- next part --------------
commit da8e3c2d6ca085aeb815d741e4d858b1216473a1
Author: Jason Merrill <jason@redhat.com>
Date: Mon Sep 12 15:01:06 2016 -0400
Fix aligned-new tests on m68k.
* c-common.c (check_cxx_fundamental_alignment_constraints): Fix
bit/byte confusion, allow large alignment for types.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 16f6548..b4f4d10 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -7836,8 +7836,7 @@ check_user_alignment (const_tree align, bool allow_zero)
return i;
}
-/*
- If in c++-11, check if the c++-11 alignment constraint with respect
+/* If in c++-11, check if the c++-11 alignment constraint with respect
to fundamental alignment (in [dcl.align]) are satisfied. If not in
c++-11 mode, does nothing.
@@ -7862,7 +7861,7 @@ check_cxx_fundamental_alignment_constraints (tree node,
int flags)
{
bool alignment_too_large_p = false;
- unsigned requested_alignment = 1U << align_log;
+ unsigned requested_alignment = (1U << align_log) * BITS_PER_UNIT;
unsigned max_align = 0;
if ((!(flags & ATTR_FLAG_CXX11) && !warn_cxx_compat)
@@ -7906,15 +7905,19 @@ check_cxx_fundamental_alignment_constraints (tree node,
}
else if (TYPE_P (node))
{
- /* Let's be liberal for types. */
- if (requested_alignment > (max_align = BIGGEST_ALIGNMENT))
+ /* Let's be liberal for types. BIGGEST_ALIGNMENT is the largest
+ alignment a built-in type can require, MAX_OFILE_ALIGNMENT is the
+ largest alignment the object file can represent, but a type that is
+ only allocated dynamically could request even larger alignment. So
+ only limit type alignment to what TYPE_ALIGN can represent. */
+ if (requested_alignment > (max_align = 8U << 28))
alignment_too_large_p = true;
}
if (alignment_too_large_p)
pedwarn (input_location, OPT_Wattributes,
"requested alignment %d is larger than %d",
- requested_alignment, max_align);
+ requested_alignment / BITS_PER_UNIT, max_align / BITS_PER_UNIT);
return !alignment_too_large_p;
}
More information about the Libstdc++
mailing list