public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/60850] New: pedantic warning behavior when casting void* to ptr-to-func
@ 2014-04-15 18:36 daniel.gutson at tallertechnologies dot com
  2014-04-15 18:53 ` [Bug c++/60850] " redi at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: daniel.gutson at tallertechnologies dot com @ 2014-04-15 18:36 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 60850
           Summary: pedantic warning behavior when casting void* to
                    ptr-to-func
           Product: gcc
           Version: 4.8.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: daniel.gutson at tallertechnologies dot com

Created attachment 32606
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=32606&action=edit
proposed fix

#pragma GCC diagnostic ignore "-pedantic"
doesn't work in cases such as:

    void* p = 0;
#pragma GCC diagnostic ignored "-pedantic"
    F* f2 = reinterpret_cast<F*>(p);

I tested the attached patch, and all passes plus the test case I added.

Please consider to add the fix in 4.8.3.
I don't have write access.

Changelog:

2014-03-31  Daniel Gutson  <daniel.gutson@tallertechnologies.com>

gcc/cp/
        * typeck.c (build_reinterpret_cast_1): Pass proper argument to
warn() in pedantic.

gcc/testsuite/g++.dg/
        * diagnostic/pedantic.C: New test case.


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

* [Bug c++/60850] pedantic warning behavior when casting void* to ptr-to-func
  2014-04-15 18:36 [Bug c++/60850] New: pedantic warning behavior when casting void* to ptr-to-func daniel.gutson at tallertechnologies dot com
@ 2014-04-15 18:53 ` redi at gcc dot gnu.org
  2014-04-15 20:41 ` daniel.gutson at tallertechnologies dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2014-04-15 18:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
patches should go to the gcc-patches list, not bugzilla


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

* [Bug c++/60850] pedantic warning behavior when casting void* to ptr-to-func
  2014-04-15 18:36 [Bug c++/60850] New: pedantic warning behavior when casting void* to ptr-to-func daniel.gutson at tallertechnologies dot com
  2014-04-15 18:53 ` [Bug c++/60850] " redi at gcc dot gnu.org
@ 2014-04-15 20:41 ` daniel.gutson at tallertechnologies dot com
  2014-04-15 21:09 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: daniel.gutson at tallertechnologies dot com @ 2014-04-15 20:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Daniel Gutson <daniel.gutson at tallertechnologies dot com> ---
It went, but I got no answer.

FWIW: http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00026.html


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

* [Bug c++/60850] pedantic warning behavior when casting void* to ptr-to-func
  2014-04-15 18:36 [Bug c++/60850] New: pedantic warning behavior when casting void* to ptr-to-func daniel.gutson at tallertechnologies dot com
  2014-04-15 18:53 ` [Bug c++/60850] " redi at gcc dot gnu.org
  2014-04-15 20:41 ` daniel.gutson at tallertechnologies dot com
@ 2014-04-15 21:09 ` redi at gcc dot gnu.org
  2014-04-16  9:11 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: redi at gcc dot gnu.org @ 2014-04-15 21:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
So keep pinging it, bugzilla isn't the right place.


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

* [Bug c++/60850] pedantic warning behavior when casting void* to ptr-to-func
  2014-04-15 18:36 [Bug c++/60850] New: pedantic warning behavior when casting void* to ptr-to-func daniel.gutson at tallertechnologies dot com
                   ` (2 preceding siblings ...)
  2014-04-15 21:09 ` redi at gcc dot gnu.org
@ 2014-04-16  9:11 ` jakub at gcc dot gnu.org
  2014-04-16 10:07 ` manu at gcc dot gnu.org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: jakub at gcc dot gnu.org @ 2014-04-16  9:11 UTC (permalink / raw)
  To: gcc-bugs

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

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> ---
As it is a C++ patch, please CC the C++ maintainer, Jason Merrill (see
MAINTAINERS file).


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

* [Bug c++/60850] pedantic warning behavior when casting void* to ptr-to-func
  2014-04-15 18:36 [Bug c++/60850] New: pedantic warning behavior when casting void* to ptr-to-func daniel.gutson at tallertechnologies dot com
                   ` (3 preceding siblings ...)
  2014-04-16  9:11 ` jakub at gcc dot gnu.org
@ 2014-04-16 10:07 ` manu at gcc dot gnu.org
  2014-04-22 20:12 ` daniel.gutson at tallertechnologies dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: manu at gcc dot gnu.org @ 2014-04-16 10:07 UTC (permalink / raw)
  To: gcc-bugs

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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-04-16
                 CC|                            |manu at gcc dot gnu.org
     Ever confirmed|0                           |1

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
(In reply to Daniel Gutson from comment #2)
> It went, but I got no answer.
> 
> FWIW: http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00026.html

Btw, the above comments are not meant to disparage you. I personally think it
is a very good idea that you created this PR and attached the patch, rather
than let it linger in the mailing list archive.

Unfortunately, the C++ FE currently has just a single one part-time maintainer,
which is also one of the main developers, so he certainly has his hands quite
full. Thus, pinging and patience are necessary. Thanks for persevering!

As a minor comment, would you mind using -Wpedantic in the test? We are slowly
trying to move to the new form. You don't need to re-test it, the behavior is
the same.

Also, when you ran the testsuite, didn't you see in the output this particular
warning? Perhaps there are already tests in place so you don't need to add a
new one.
>From gcc-bugs-return-449153-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Apr 16 11:23:08 2014
Return-Path: <gcc-bugs-return-449153-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 26898 invoked by alias); 16 Apr 2014 11:23:07 -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 26864 invoked by uid 48); 16 Apr 2014 11:23:03 -0000
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/60852] [4.8/4.9/4.10 Regression] boost::has_complement of enum class does not compile
Date: Wed, 16 Apr 2014 11:23:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: jakub at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.8.3
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-60852-4-edqcBvdPPs@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-60852-4@http.gcc.gnu.org/bugzilla/>
References: <bug-60852-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: 2014-04/txt/msg01173.txt.bz2
Content-length: 569

http://gcc.gnu.org/bugzilla/show_bug.cgi?id`852

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

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

--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Given that the patch has been there for quite some time already, I think it is
important to first understand if this testcase is valid or not, before
considering reversion.
CCing Alex as well.


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

* [Bug c++/60850] pedantic warning behavior when casting void* to ptr-to-func
  2014-04-15 18:36 [Bug c++/60850] New: pedantic warning behavior when casting void* to ptr-to-func daniel.gutson at tallertechnologies dot com
                   ` (4 preceding siblings ...)
  2014-04-16 10:07 ` manu at gcc dot gnu.org
@ 2014-04-22 20:12 ` daniel.gutson at tallertechnologies dot com
  2014-07-26  2:37 ` tony at kelman dot net
  2014-07-28 16:38 ` tony at kelman dot net
  7 siblings, 0 replies; 9+ messages in thread
From: daniel.gutson at tallertechnologies dot com @ 2014-04-22 20:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Daniel Gutson <daniel.gutson at tallertechnologies dot com> ---
Thanks Manuel.

1) I didn't see a warning regarding the old use of -pedantic rather than
-Wpedantic

2) I'll change that, after the C++ FE maintainer sees the patch in order to not
pollute the thread with more patches. I didn't know about the deprecation of
-pedantic, thanks!

And thanks for your encouraging words!


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

* [Bug c++/60850] pedantic warning behavior when casting void* to ptr-to-func
  2014-04-15 18:36 [Bug c++/60850] New: pedantic warning behavior when casting void* to ptr-to-func daniel.gutson at tallertechnologies dot com
                   ` (5 preceding siblings ...)
  2014-04-22 20:12 ` daniel.gutson at tallertechnologies dot com
@ 2014-07-26  2:37 ` tony at kelman dot net
  2014-07-28 16:38 ` tony at kelman dot net
  7 siblings, 0 replies; 9+ messages in thread
From: tony at kelman dot net @ 2014-07-26  2:37 UTC (permalink / raw)
  To: gcc-bugs

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

Tony Kelman <tony at kelman dot net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tony at kelman dot net

--- Comment #7 from Tony Kelman <tony at kelman dot net> ---
Applying this change has made GCC 4.8.3 unusable for a large body of legacy
code. Not good for a patch release. Anything that uses old versions of autoconf
where the AC_CHECK_DECL probe used exactly this kind of cast, and has
-pedantic-errors in its CFLAGS, now gets completely different results from
configure, in many cases failing to build.

I realize the right solution is to update to a newer version of autoconf in
these cases, but there are many thousands of lines of custom autoconf macros
out there that make that much easier said than done. Or remove
-pedantic-errors, but that could lead to a different set of problems. As GCC
4.8.3 makes it into more distributions this is going to become a maintenance
burden, forcing a great deal of patching around the problem or recommending
users install different compiler versions than their default.


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

* [Bug c++/60850] pedantic warning behavior when casting void* to ptr-to-func
  2014-04-15 18:36 [Bug c++/60850] New: pedantic warning behavior when casting void* to ptr-to-func daniel.gutson at tallertechnologies dot com
                   ` (6 preceding siblings ...)
  2014-07-26  2:37 ` tony at kelman dot net
@ 2014-07-28 16:38 ` tony at kelman dot net
  7 siblings, 0 replies; 9+ messages in thread
From: tony at kelman dot net @ 2014-07-28 16:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Tony Kelman <tony at kelman dot net> ---
Sure. In a configure.ac, (in this case using autoconf 2.59, not sure the most
recent version for which this applies) a macro like

AC_CHECK_DECL([rand],[AC_DEFINE([HAVE_RAND],[1],
                                [Define to 1 if function rand is
available])],,[
#ifdef HAVE_CSTDLIB
# include <cstdlib>
#else
# ifdef HAVE_STDLIB_H
#  include <stdlib.h>
# endif
#endif
])

expands into a probe that looks like this (plus the above includes)

int
main ()
{
#ifndef rand
  char *p = (char *) rand;
#endif

  ;
  return 0;
}

This compiles successfully (with a warning "ISO C++ forbids casting between
pointer-to-function and pointer-to-object [enabled by default]", but autoconf
cares more about the exit code) when -pedantic-errors is given with GCC 4.8.2,
and every other released GCC version I'm aware of, except that it errors with
4.8.3. The message with 4.8.3 is the same, but now it's an error and listed as
[-Werror=pedantic], and cc1plus reports "some warnings being treated as
errors."

The new behavior is arguably more correct, but has unfortunate consequences
with respect to backwards-compatibility.


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

end of thread, other threads:[~2014-07-28 16:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-15 18:36 [Bug c++/60850] New: pedantic warning behavior when casting void* to ptr-to-func daniel.gutson at tallertechnologies dot com
2014-04-15 18:53 ` [Bug c++/60850] " redi at gcc dot gnu.org
2014-04-15 20:41 ` daniel.gutson at tallertechnologies dot com
2014-04-15 21:09 ` redi at gcc dot gnu.org
2014-04-16  9:11 ` jakub at gcc dot gnu.org
2014-04-16 10:07 ` manu at gcc dot gnu.org
2014-04-22 20:12 ` daniel.gutson at tallertechnologies dot com
2014-07-26  2:37 ` tony at kelman dot net
2014-07-28 16:38 ` tony at kelman dot net

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