bug-groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #62398] [troff] input.cpp: argument "len" is zero in "new unsigned


From: G. Branden Robinson
Subject: [bug #62398] [troff] input.cpp: argument "len" is zero in "new unsigned char[len]"
Date: Mon, 10 Jul 2023 04:44:14 -0400 (EDT)

Update of bug #62398 (project groff):

                  Status:         Ready for Merge => Fixed                  
             Open/Closed:                    Open => Closed                 
         Planned Release:                    None => 1.24.0                 
                 Summary: .../troff/input.cpp: argument "len" is zero in "new
unsigned char[len]" => [troff] input.cpp: argument "len" is zero in "new
unsigned char[len]"

    _______________________________________________________

Follow-up Comment #11:


commit 5a80c2412b89f64a31236ab2ee5719a94a6b01e3
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
Date:   Mon Apr 3 19:30:56 2023 -0500

    [troff]: Skip allocation of zero-length arrays.
    
    * src/roff/troff/input.cpp (temp_iterator::temp_iterator): Skip
      allocation of zero-length arrays.  Resolves "-Walloc-zero" warning
      from GCC.
    
    Fixes <https://savannah.gnu.org/bugs/?62398>.  Thanks to Bjarni Ingi
    Gislason for the report.
    
    It is not necessary to make conditional the subsequent `delete[]` of a
    null pointer.  "If the _delete-expression_ calls the implementation
    deallocation function (3.7.3.2), and if the operand of the delete
    expression is not the null pointer constant, the deallocation function
    will deallocate the storage referenced by the pointer thus rendering the
    pointer invalid" (ISO/IEC 14882-1998, ยง5.3.5, paragraph 4).  Or as
    Stroustrup puts it, "Applying _delete_ to zero has no effect." (_The C++
    Programming Language, Special Edition_, p. 128).
    
    Also annotate some null pointers with `nullptr` comments to ease any
    future transition to C++11, which defines it as a keyword.




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?62398>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]