public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/112377] New: Implement -Walloc-size in c++
@ 2023-11-04  8:22 dcb314 at hotmail dot com
  2023-11-04  9:50 ` [Bug c++/112377] " uecker at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dcb314 at hotmail dot com @ 2023-11-04  8:22 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112377
           Summary: Implement -Walloc-size in c++
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dcb314 at hotmail dot com
  Target Milestone: ---

Following on from discussion in bug report 112347,
in file gcc/c-family/c.opt, is the new text

Walloc-size
C ObjC Var(warn_alloc_size) Warning LangEnabledBy(C ObjC, Wextra)
Warn when allocating insufficient storage for the target type of the assigned
pointer.

IMHO, it should say:

Walloc-size
C ObjC Var(warn_alloc_size) Warning LangEnabledBy(C ObjC C++, Wextra)
Warn when allocating insufficient storage for the target type of the assigned
pointer.

I think that should be enough to implement the new warning for C++.

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

* [Bug c++/112377] Implement -Walloc-size in c++
  2023-11-04  8:22 [Bug c++/112377] New: Implement -Walloc-size in c++ dcb314 at hotmail dot com
@ 2023-11-04  9:50 ` uecker at gcc dot gnu.org
  2023-11-04  9:50 ` uecker at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: uecker at gcc dot gnu.org @ 2023-11-04  9:50 UTC (permalink / raw)
  To: gcc-bugs

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

uecker at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2023-11-04
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1

--- Comment #1 from uecker at gcc dot gnu.org ---
Confirmed. 

But this change would not be enough. The warning is implemented in the C
front-end which which is separate from the C++ FE. Possibly, the code for the
warning could be shared, but I do not know.

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

* [Bug c++/112377] Implement -Walloc-size in c++
  2023-11-04  8:22 [Bug c++/112377] New: Implement -Walloc-size in c++ dcb314 at hotmail dot com
  2023-11-04  9:50 ` [Bug c++/112377] " uecker at gcc dot gnu.org
@ 2023-11-04  9:50 ` uecker at gcc dot gnu.org
  2023-11-04 17:23 ` egallager at gcc dot gnu.org
  2023-11-06 10:21 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: uecker at gcc dot gnu.org @ 2023-11-04  9:50 UTC (permalink / raw)
  To: gcc-bugs

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

uecker at gcc dot gnu.org changed:

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

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

* [Bug c++/112377] Implement -Walloc-size in c++
  2023-11-04  8:22 [Bug c++/112377] New: Implement -Walloc-size in c++ dcb314 at hotmail dot com
  2023-11-04  9:50 ` [Bug c++/112377] " uecker at gcc dot gnu.org
  2023-11-04  9:50 ` uecker at gcc dot gnu.org
@ 2023-11-04 17:23 ` egallager at gcc dot gnu.org
  2023-11-06 10:21 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: egallager at gcc dot gnu.org @ 2023-11-04 17:23 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Gallager <egallager at gcc dot gnu.org> changed:

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

--- Comment #2 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to David Binderman from comment #0)
> Following on from discussion in bug report 112347,
> in file gcc/c-family/c.opt, is the new text
> 
> Walloc-size
> C ObjC Var(warn_alloc_size) Warning LangEnabledBy(C ObjC, Wextra)
> Warn when allocating insufficient storage for the target type of the
> assigned pointer.
> 
> IMHO, it should say:
> 
> Walloc-size
> C ObjC Var(warn_alloc_size) Warning LangEnabledBy(C ObjC C++, Wextra)
> Warn when allocating insufficient storage for the target type of the
> assigned pointer.
> 
> I think that should be enough to implement the new warning for C++.

If adding it to C++, then IMO it ought to be enabled for ObjC++, too, since the
current implementation is for both C and ObjC.

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

* [Bug c++/112377] Implement -Walloc-size in c++
  2023-11-04  8:22 [Bug c++/112377] New: Implement -Walloc-size in c++ dcb314 at hotmail dot com
                   ` (2 preceding siblings ...)
  2023-11-04 17:23 ` egallager at gcc dot gnu.org
@ 2023-11-06 10:21 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2023-11-06 10:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to David Binderman from comment #0)
> I think that should be enough to implement the new warning for C++.

Certainly not. Apart from the fact that there's a lot more needed than just
making the option accepted by the C++ front end, there's the question of what
it should actually do.

Would it only warn for malloc, calloc etc., or operator new as well?

And what about warning about alignment for overaligned types, both when using
operator new (with or without a std::align_val_t argument) and malloc. Should
that be a separate warning?

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

end of thread, other threads:[~2023-11-06 10:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-04  8:22 [Bug c++/112377] New: Implement -Walloc-size in c++ dcb314 at hotmail dot com
2023-11-04  9:50 ` [Bug c++/112377] " uecker at gcc dot gnu.org
2023-11-04  9:50 ` uecker at gcc dot gnu.org
2023-11-04 17:23 ` egallager at gcc dot gnu.org
2023-11-06 10:21 ` redi 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).