public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/65695] New: [4.9/5 Regression] calling constexpr constructor with pointer-to-member is not a constant expression
@ 2015-04-08 10:59 redi at gcc dot gnu.org
  2015-04-08 11:02 ` [Bug c++/65695] [4.9/5 Regression] NSDMI " redi at gcc dot gnu.org
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: redi at gcc dot gnu.org @ 2015-04-08 10:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 65695
           Summary: [4.9/5 Regression] calling constexpr constructor with
                    pointer-to-member is not a constant expression
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org

From https://gcc.gnu.org/ml/gcc-help/2015-04/msg00034.html

template <typename T>
struct Bar
{
    using MemberFuncT = int (T::*)();

    MemberFuncT h_;
    constexpr Bar(MemberFuncT h) : h_{h}
    {
    }
};

struct Foo
{
    int test()
    {
        return -1;
    }

    // this causes the brace-enclosed initializer error message:
    static constexpr Bar<Foo> bar = Bar<Foo>(&Foo::test);

    // but this line does not:
    // static constexpr Bar<Foo> bar = Bar<Foo>(nullptr);

    // this line also causes the error message, unless you remove the
    // explict constructor in Bar.
    // static constexpr Bar<Foo> bar = {&Foo::test};
};

constexpr Bar<Foo> Foo::bar;

// the line below does not cause any problems, either:
// static constexpr Bar<Foo> bar = Bar<Foo>(&Foo::test);

int main(void)
{
    Foo f;
    return (f.*(Foo::bar.h_))();
}

c.cc:20:56: error: ‘Bar<Foo>{&Foo::test}’ is not a constant expression
     static constexpr Bar<Foo> bar = Bar<Foo>(&Foo::test);
                                                        ^

Clang and EDG accept the code.
>From gcc-bugs-return-482988-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Apr 08 11:01:58 2015
Return-Path: <gcc-bugs-return-482988-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 24805 invoked by alias); 8 Apr 2015 11:01:58 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 24701 invoked by uid 48); 8 Apr 2015 11:01:54 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/65689] [5 Regression][AArch64] S constraint fails for inline asm at -O0
Date: Wed, 08 Apr 2015 11:01:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords: rejects-valid
X-Bugzilla-Severity: minor
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P2
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-65689-4-XBZcc5CYpa@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-65689-4@http.gcc.gnu.org/bugzilla/>
References: <bug-65689-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-04/txt/msg00540.txt.bz2
Content-length: 1195

https://gcc.gnu.org/bugzilla/show_bug.cgi?ide689

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Adding a hack where stmt.c (parse_input_constraint) so that it handles
case 'S':
the same as say case 'i':
fixes the test, so it is all about whether the expander and middle-end thinks
that "S" constraint allows_reg || allows_mem (right now both, ideally none).
So, to fix this, perhaps hack up genpreds.c, so that it generates another
function or two which returns true if the constraint can be easily proved not
to allow reg (or not to allow mem).
Say "S" is:
  (and (match_code "const,symbol_ref,label_ref")
       (match_test "aarch64_symbolic_address_p (op)")))
and so genpreds can conservatively assume match_test can return anything, but
match_code clearly doesn't satisfy a reg/subreg nor mem (requires something
other), so process_{input,output}_constraint should be able to safely set both
of those to false.


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-04-23 13:25 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-08 10:59 [Bug c++/65695] New: [4.9/5 Regression] calling constexpr constructor with pointer-to-member is not a constant expression redi at gcc dot gnu.org
2015-04-08 11:02 ` [Bug c++/65695] [4.9/5 Regression] NSDMI " redi at gcc dot gnu.org
2015-04-08 11:04 ` redi at gcc dot gnu.org
2015-04-08 11:08 ` redi at gcc dot gnu.org
2015-04-08 11:10 ` rguenth at gcc dot gnu.org
2015-04-09  9:15 ` rguenth at gcc dot gnu.org
2015-04-10 10:50 ` jaehnesn at gmx dot de
2015-04-10 11:18 ` jaehnesn at gmx dot de
2015-04-10 11:34 ` daniel.kruegler at googlemail dot com
2015-04-10 12:02 ` jaehnesn at gmx dot de
2015-04-11 14:57 ` jason at gcc dot gnu.org
2015-04-14 16:03 ` [Bug c++/65695] [4.9/5/6 " jason at gcc dot gnu.org
2015-04-22 20:53 ` jason at gcc dot gnu.org
2015-04-23 13:21 ` jason at gcc dot gnu.org
2015-04-23 13:25 ` jason at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).