[Bug c++/85662] [8/9 Regression] "error: non-constant condition for static assertion" from __builtin_offsetof in C++

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed May 30 07:21:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85662

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Author: jakub
Date: Wed May 30 07:20:58 2018
New Revision: 260916

URL: https://gcc.gnu.org/viewcvs?rev=260916&root=gcc&view=rev
Log:
        Backported from mainline
        2018-05-10  Jakub Jelinek  <jakub@redhat.com>

        PR c++/85662
        * c-common.h (fold_offsetof_1): Removed.
        (fold_offsetof): Add TYPE argument defaulted to size_type_node and
        CTX argument defaulted to ERROR_MARK.
        * c-common.c (fold_offsetof_1): Renamed to ...
        (fold_offsetof): ... this.  Remove wrapper function.  Add TYPE
        argument, convert the pointer constant to TYPE and use size_binop
        with PLUS_EXPR instead of fold_build_pointer_plus if type is not
        a pointer type.  Adjust recursive calls.

        * c-fold.c (c_fully_fold_internal): Use fold_offsetof rather than
        fold_offsetof_1, pass TREE_TYPE (expr) as TYPE to it and drop the
        fold_convert_loc.
        * c-typeck.c (build_unary_op): Use fold_offsetof rather than
        fold_offsetof_1, pass argtype as TYPE to it and drop the
        fold_convert_loc.

        * cp-gimplify.c (cp_fold): Use fold_offsetof rather than
        fold_offsetof_1, pass TREE_TYPE (x) as TYPE to it and drop the
        fold_convert.

        * g++.dg/ext/offsetof2.C: New test.

Added:
    branches/gcc-8-branch/gcc/testsuite/g++.dg/ext/offsetof2.C
Modified:
    branches/gcc-8-branch/gcc/c-family/ChangeLog
    branches/gcc-8-branch/gcc/c-family/c-common.c
    branches/gcc-8-branch/gcc/c-family/c-common.h
    branches/gcc-8-branch/gcc/c/ChangeLog
    branches/gcc-8-branch/gcc/c/c-fold.c
    branches/gcc-8-branch/gcc/c/c-typeck.c
    branches/gcc-8-branch/gcc/cp/ChangeLog
    branches/gcc-8-branch/gcc/cp/cp-gimplify.c
    branches/gcc-8-branch/gcc/testsuite/ChangeLog


More information about the Gcc-bugs mailing list