[Bug c++/91055] alignof () evaluated before layout is complete?
kamleshbhalui at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Oct 16 16:21:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91055
Kamlesh Kumar <kamleshbhalui at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |kamleshbhalui at gmail dot com
--- Comment #1 from Kamlesh Kumar <kamleshbhalui at gmail dot com> ---
This fixes it.
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index f427c4f4d3e..928dc887956 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -1791,6 +1791,11 @@ cxx_alignof_expr (tree e, tsubst_flags_t complain)
if (e == error_mark_node)
return error_mark_node;
+ if (current_class_type && TYPE_BEING_DEFINED (current_class_type))
+ {
+ error ("invalid application of %<alignof%> to a field of a class still
being defined");
+ return error_mark_node;
+ }
if (processing_template_decl)
{
e = build_min (ALIGNOF_EXPR, size_type_node, e);
More information about the Gcc-bugs
mailing list