public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/113298] New: RFE: allow suppressing warnings for void * conversions with -fpermissive
@ 2024-01-09 20:10 hpa at zytor dot com
  2024-01-09 20:23 ` [Bug c++/113298] " redi at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: hpa at zytor dot com @ 2024-01-09 20:10 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 113298
           Summary: RFE: allow suppressing warnings for void * conversions
                    with -fpermissive
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hpa at zytor dot com
  Target Milestone: ---

-fpermissive downgrades some errors to warnings, but there doesn't seem to be
any -W options to suppress those warnings, and -fpermissive itself is a fairly
wide switch.

Having individual -W options for the various -fpermissive events would allow
the programmer to pick what extensions to allow unconditionally, which to warn
for, and which to error out for (-Werror=).

Allowing void * to be converted to a pointer to a POD structure is particularly
useful in the process of moving a project from C to C++.

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

* [Bug c++/113298] RFE: allow suppressing warnings for void * conversions with -fpermissive
  2024-01-09 20:10 [Bug c++/113298] New: RFE: allow suppressing warnings for void * conversions with -fpermissive hpa at zytor dot com
@ 2024-01-09 20:23 ` redi at gcc dot gnu.org
  2024-01-09 23:09 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-09 20:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to H. Peter Anvin from comment #0)
> Having individual -W options for the various -fpermissive events would allow
> the programmer to pick what extensions to allow unconditionally, which to
> warn for, and which to error out for (-Werror=).

That creates a huge number of different permutations of language subsets. The
things that -fpermissive allows should be considered as big red flags to be
fixed, not as extensions.

So IMHO it's a feature not a bug that -fpermissive is a very blunt instrument.

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

* [Bug c++/113298] RFE: allow suppressing warnings for void * conversions with -fpermissive
  2024-01-09 20:10 [Bug c++/113298] New: RFE: allow suppressing warnings for void * conversions with -fpermissive hpa at zytor dot com
  2024-01-09 20:23 ` [Bug c++/113298] " redi at gcc dot gnu.org
@ 2024-01-09 23:09 ` pinskia at gcc dot gnu.org
  2024-01-09 23:19 ` hpa at zytor dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-09 23:09 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
           Severity|normal                      |enhancement

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

* [Bug c++/113298] RFE: allow suppressing warnings for void * conversions with -fpermissive
  2024-01-09 20:10 [Bug c++/113298] New: RFE: allow suppressing warnings for void * conversions with -fpermissive hpa at zytor dot com
  2024-01-09 20:23 ` [Bug c++/113298] " redi at gcc dot gnu.org
  2024-01-09 23:09 ` pinskia at gcc dot gnu.org
@ 2024-01-09 23:19 ` hpa at zytor dot com
  2024-01-10 18:04 ` redi at gcc dot gnu.org
  2024-01-10 18:08 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: hpa at zytor dot com @ 2024-01-09 23:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from H. Peter Anvin <hpa at zytor dot com> ---
You're not wrong per se. Arguably the problem (and many others) would be better
solved by allowing user-specified conversations that are not member functions.
In that case one could do:

// Set the properties/types for which
// we allow pointer conversations from
// void *
template <typename T>
concept void_pointer_convertible = ...

template <typename V>
concept some_void_type = std::is_void_v<V>;

template <void_pointer_convertible T, some_void_type V>
operator T * (V *ptr) { return static_cast<T *>(ptr); }

... and now the programmer has full control over exactly what they wish to
permit.

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

* [Bug c++/113298] RFE: allow suppressing warnings for void * conversions with -fpermissive
  2024-01-09 20:10 [Bug c++/113298] New: RFE: allow suppressing warnings for void * conversions with -fpermissive hpa at zytor dot com
                   ` (2 preceding siblings ...)
  2024-01-09 23:19 ` hpa at zytor dot com
@ 2024-01-10 18:04 ` redi at gcc dot gnu.org
  2024-01-10 18:08 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: redi at gcc dot gnu.org @ 2024-01-10 18:04 UTC (permalink / raw)
  To: gcc-bugs

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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2024-01-10
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
That said, when considering moving a very large project from C to C++, or even
just parts of it, needing to do such things just gets in the way and slows you
down.

I think adding separate diagnostic controls for *some* parts of what
-fpermissive controls probably makes sense.

Maybe you can provide other examples of particular warnings that you'd like to
be more fine-grained? Implicit conversion from void* to T* is one, as already
give above.

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

* [Bug c++/113298] RFE: allow suppressing warnings for void * conversions with -fpermissive
  2024-01-09 20:10 [Bug c++/113298] New: RFE: allow suppressing warnings for void * conversions with -fpermissive hpa at zytor dot com
                   ` (3 preceding siblings ...)
  2024-01-10 18:04 ` redi at gcc dot gnu.org
@ 2024-01-10 18:08 ` jason at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: jason at gcc dot gnu.org @ 2024-01-10 18:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Jason Merrill <jason at gcc dot gnu.org> ---
GCC trunk now lets us associate permerrors with a -W flag, so this would be
pretty trivial to do.  It's a matter of adding an option to c-family/c.opt and
doc/invoke.texi and changing the relevant permerror call to permerror_opt.

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

end of thread, other threads:[~2024-01-10 18:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-09 20:10 [Bug c++/113298] New: RFE: allow suppressing warnings for void * conversions with -fpermissive hpa at zytor dot com
2024-01-09 20:23 ` [Bug c++/113298] " redi at gcc dot gnu.org
2024-01-09 23:09 ` pinskia at gcc dot gnu.org
2024-01-09 23:19 ` hpa at zytor dot com
2024-01-10 18:04 ` redi at gcc dot gnu.org
2024-01-10 18:08 ` 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).