public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/57869] New: [C++11] Casting a object pointer to a function pointer should not warn about a forbidden conversion
@ 2013-07-09 19:52 daniel.kruegler at googlemail dot com
  2013-07-09 22:19 ` [Bug c++/57869] " paolo.carlini at oracle dot com
  0 siblings, 1 reply; 2+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-07-09 19:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57869

            Bug ID: 57869
           Summary: [C++11] Casting a object pointer to a function pointer
                    should not warn about a forbidden conversion
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: daniel.kruegler at googlemail dot com

gcc 4.9.0 20130616 (experimental) diagnoses a warning for the following code
compiled with the flags:

-Wall -pedantic -std=c++11

//-------------------------------------
void* po = 0;
void (*pf)() = reinterpret_cast<decltype(pf)>(po); // #2
static_assert(sizeof(po) >= sizeof(pf), "Conversion not supported");
//-------------------------------------

"main.cpp|2|warning: ISO C++ forbids casting between pointer-to-function and
pointer-to-object [enabled by default]"

Given that 5.2.10 p8 says:

"Converting a function pointer to an object pointer type or vice versa is
conditionally-supported."

and since to my knowledge gcc supports such conversions (without that ::dlopen
wouldn't work), the warning should be removed in the context of C++11.


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

* [Bug c++/57869] [C++11] Casting a object pointer to a function pointer should not warn about a forbidden conversion
  2013-07-09 19:52 [Bug c++/57869] New: [C++11] Casting a object pointer to a function pointer should not warn about a forbidden conversion daniel.kruegler at googlemail dot com
@ 2013-07-09 22:19 ` paolo.carlini at oracle dot com
  0 siblings, 0 replies; 2+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-07-09 22:19 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57869

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-07-09
           Assignee|unassigned at gcc dot gnu.org      |paolo.carlini at oracle dot com
   Target Milestone|---                         |4.9.0
     Ever confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Seems easy to fix. We got this (outdated) comment:

      if (pedantic && (complain & tf_warning))
    /* Only issue a warning, as we have always supported this
       where possible, and it is necessary in some cases.  DR 195
       addresses this issue, but as of 2004/10/26 is still in
       drafting.  */
    warning (0, "ISO C++ forbids casting between pointer-to-function and
pointer-to-object");

thus it seems just matter of suppressing he warning for c++11 (and c++1y) and
updating the comment.


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

end of thread, other threads:[~2013-07-09 22:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-09 19:52 [Bug c++/57869] New: [C++11] Casting a object pointer to a function pointer should not warn about a forbidden conversion daniel.kruegler at googlemail dot com
2013-07-09 22:19 ` [Bug c++/57869] " paolo.carlini at oracle dot com

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).