[Bug c++/89367] Constexpr expression is not constexpr in template, but is constexpr in non-template.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89367 Patrick Palka changed: What|Removed |Added Resolution|--- |FIXED CC||ppalka at gcc dot gnu.org Target Milestone|--- |12.0 Status|UNCONFIRMED |RESOLVED --- Comment #9 from Patrick Palka --- All testcases here seem to be fixed for GCC 12 by the fix for PR94716.
[Bug c++/89367] Constexpr expression is not constexpr in template, but is constexpr in non-template.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89367 Andrew Pinski changed: What|Removed |Added See Also||https://gcc.gnu.org/bugzill ||a/show_bug.cgi?id=94716 --- Comment #8 from Andrew Pinski --- Very similar to PR 94716. The original code in comment #0 might be solved by https://gcc.gnu.org/pipermail/gcc-patches/2021-December/586553.html (when it gets approved/applied). (In reply to Frank Secilia from comment #4) > Created attachment 45743 [details] > alternative repro case using pointers to method There is another bug recording pointer to method function comparisons too.
[Bug c++/89367] Constexpr expression is not constexpr in template, but is constexpr in non-template.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89367 --- Comment #7 from Jakub Jelinek --- If the compiler can prove the addresses are the same or are different, then sure, it will evaluate to constant 0 or 1. The question is if the compiler must be able to prove it in all cases (which is impossible, in some cases it needs to do runtime checks and then it can't be a constant expression), and if the problematic cases include the above ones.
[Bug c++/89367] Constexpr expression is not constexpr in template, but is constexpr in non-template.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89367 --- Comment #6 from Frank Secilia --- I can't find anything in the standard under `constant expressions` or `converted constant expressions` that explicitly allows non-null pointer-to-member-functions in constexpr contexts, but I also can't find anything since N4268 that explicitly forbids them. It looks like icc and msvc accept this as well. Here are some godbolt results for x86_64: clang 7.0 - https://godbolt.org/z/sg-da1 icc 19.0.1 - https://godbolt.org/z/X8eqy1 msvc 19.16 - https://godbolt.org/z/5gbv83
[Bug c++/89367] Constexpr expression is not constexpr in template, but is constexpr in non-template.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89367 --- Comment #5 from Frank Secilia --- Created attachment 45744 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45744=edit alternative verbose compiler output
[Bug c++/89367] Constexpr expression is not constexpr in template, but is constexpr in non-template.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89367 --- Comment #4 from Frank Secilia --- Created attachment 45743 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45743=edit alternative repro case using pointers to method Here is a similar case using pointers to methods. I'm honestly not sure if this is even allowed by the standard, but it works as expected with clang.
[Bug c++/89367] Constexpr expression is not constexpr in template, but is constexpr in non-template.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89367 Jakub Jelinek changed: What|Removed |Added CC||hubicka at gcc dot gnu.org, ||jakub at gcc dot gnu.org, ||jason at gcc dot gnu.org, ||mpolacek at gcc dot gnu.org, ||redi at gcc dot gnu.org --- Comment #3 from Jakub Jelinek --- With -fpic it actually rejects both static_asserts. In all the cases, it is symtab_node::equal_address_to that attempts to decide if the two VAR_DECLs need to be the same or distinct or unknown. Without templates and without -fpic that function returns true, because both are defined locally and we can easily decide that they must be different, but with -fpic, the generic code allows them to be interposed and fails. Even without -fpic, for templates the variables are DECL_COMDAT and thus not really known if defined by the current or some other TU. No idea if C++ standard says anything here and constexpr evaluation shouldn't use some different rules (or in addition to what the generic code says).
[Bug c++/89367] Constexpr expression is not constexpr in template, but is constexpr in non-template.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89367 --- Comment #1 from Frank Secilia --- Created attachment 45738 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45738=edit verbose compiler output
[Bug c++/89367] Constexpr expression is not constexpr in template, but is constexpr in non-template.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89367 --- Comment #2 from Frank Secilia --- I searched for existing bugs. I don't know the codebase, but I think it may be another repro case for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53181.