public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/85795] bad_alloc thrown from allocation function when bad_array_length is expected
       [not found] <bug-85795-4@http.gcc.gnu.org/bugzilla/>
@ 2022-03-28  9:21 ` redi at gcc dot gnu.org
  2022-03-28  9:21 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-28  9:21 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Erroneous expressions include negative ones, as in PR 105077:

#include <new>
#include <stdexcept>
int main()  
{
  try 
  {
    int negative = -1;
    new char[negative];
  } 
  catch(const std::bad_array_new_length &e) 
  {
  }
  return 0;
}

This throws bad_alloc instead of bad_array_new_length.

PR 99934 is another example where we should not call the allocation function,
but the FE should return a nullptr instead of throwing.

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

* [Bug c++/85795] bad_alloc thrown from allocation function when bad_array_length is expected
       [not found] <bug-85795-4@http.gcc.gnu.org/bugzilla/>
  2022-03-28  9:21 ` [Bug c++/85795] bad_alloc thrown from allocation function when bad_array_length is expected redi at gcc dot gnu.org
@ 2022-03-28  9:21 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 2+ messages in thread
From: redi at gcc dot gnu.org @ 2022-03-28  9:21 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |chumarshal at foxmail dot com

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
*** Bug 105077 has been marked as a duplicate of this bug. ***

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

end of thread, other threads:[~2022-03-28  9:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-85795-4@http.gcc.gnu.org/bugzilla/>
2022-03-28  9:21 ` [Bug c++/85795] bad_alloc thrown from allocation function when bad_array_length is expected redi at gcc dot gnu.org
2022-03-28  9: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).