public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "adrien at guinet dot me" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/52892] Function pointer loses constexpr qualification Date: Tue, 29 May 2012 09:28:00 -0000 [thread overview] Message-ID: <bug-52892-4-alBVUSzeMC@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-52892-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52892 Adrien Guinet <adrien at guinet dot me> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |adrien at guinet dot me --- Comment #2 from Adrien Guinet <adrien at guinet dot me> 2012-05-29 09:26:29 UTC --- Hello everyone, Im ay have an issue related to this issue, if that can help: #include <iostream> struct A { void f(int i) { std::cout << "f " << i << " " << _i << std::endl; } void f2(int i) { std::cout << "f2 " << i << " " << _i << std::endl; } int _i; }; template <typename F, F f> struct class_f { typedef F f_type; static constexpr f_type f_value = f; static constexpr f_type get() { return f; } }; int main() { typedef class_f<decltype(&A::f), &A::f> ff_t; // This does not compile class_f<ff_t::f_type, ff_t::f_value> ff; // This does not compile either class_f<ff_t::f_type, static_cast<ff_t::f_type>(&A::f)> ff2; // This does class_f<ff_t::f_type, &A::f> ff_works; } It looks like using a function pointer that has been "instantiated" as an "f_type" makes the compilation fails. here is the output of g++-4.7 with the first "failing" tests : $ g++-4.7 -std=c++0x ftempl.cpp ftempl.cpp: In function ‘int main()’: ftempl.cpp:24:37: error: could not convert template argument ‘class_f<void (A::*)(int), &A::f>::f_value’ to ‘void (A::*)(int)’ ftempl.cpp:24:41: error: invalid type in declaration before ‘;’ token $ g++-4.7 --version g++-4.7 (Debian 4.7.0-8) 4.7.0
next prev parent reply other threads:[~2012-05-29 9:28 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-04-06 18:58 [Bug c++/52892] New: " EricMCornelius at gmail dot com 2012-04-07 13:16 ` [Bug c++/52892] " daniel.kruegler at googlemail dot com 2012-05-29 9:28 ` adrien at guinet dot me [this message] 2013-05-02 14:57 ` paolo.carlini at oracle dot com 2014-08-27 17:04 ` paolo at gcc dot gnu.org 2014-08-27 17:05 ` paolo.carlini at oracle dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-52892-4-alBVUSzeMC@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).