bugmake - Bugs: bug #60798, Make does not compile with GCC...

 
 

bug #60798: Make does not compile with GCC 11.1.0

Submitter:  None
Submitted:  Fri 18 Jun 2021 04:36:51 PM UTC
   
 
Severity:  3 - Normal Item Group:  Build/Install
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  None Operating System:  None
Fixed Release:  4.4 Triage Status:  Small Effort
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 19 Dec 2021 10:02:47 PM UTC, comment #5: 

Thanks Jouke.  I did a bit of reworking on the second patch but hopefully it still doesn't give warnings.

Paul D. Smith <psmith>
Group administrator
Sat 04 Dec 2021 03:32:37 PM UTC, comment #4: 

As a sort of exercise, I got rid of the final warning too. This required some moving code around and I duplicated the `strchr` call and the `p[-1] != '\\'` test. Let me know if these changes make any sense.

While at it, I also added an update to the string length variable which was missing from the old code.

With the last two patches, Make compiles with no warnings on my Arch Linux system with GCC 11.1.0.

(file #52425)

Jouke Witteveen <jwitteveen>
Fri 03 Dec 2021 04:59:55 PM UTC, comment #3: 

I expanded the patch a bit to also silence a maybe-uninitialized error.

With GCC11, there is now only one warning remaining, which is the return-local-addr warning in src/read.c:2534 (find_percent_cached). The code is correct, but GCC fails to prove that the final stack-bound allocation (if applicable) will be copied to the string cache.

(file #52422)

Jouke Witteveen <jwitteveen>
Fri 03 Dec 2021 12:22:44 PM UTC, comment #2: 

I couldn't find any signs of GCC becoming clever enough to detect why this code is correct. Minor code changes can silence the stringop-overflow warnings.

The next warning I get (GCC11) is a return-local-addr warning in src/read.c:2534 (find_percent_cached). Maybe GCC doesn't recognize alloca as a heap allocation? Just guessing; this warning was not obvious to me.

(file #52420)

Jouke Witteveen <jwitteveen>
Fri 18 Jun 2021 04:53:32 PM UTC, comment #1: 

FWIW, this warning is not valid in this situation.  The code is correct; p will always be pointing into a valid buffer and never pointing at the first character in that buffer, so p[-1] always points to valid memory.

When building code for production use, you should never use -Werror.

Paul D. Smith <psmith>
Group administrator
Fri 18 Jun 2021 04:36:51 PM UTC, original submission:  

I cloned the current make git repository:
https://git.savannah.gnu.org/git/emacs.git

Then I compiled it with GCC 11.1.0. It triggers the following error:
src/main.c:1954:13: error: writes 1 byte in a region of size 0 [-Werror=stringop-overflow=]
2006 |       p[-1] = '\0';
|       ~~~~~~^~~~~~

It compiles with GCC 8.3.0 though.

This error was introduced in GCC 10
https://gcc.gnu.org/gcc-10/changes.html#c-family as "Enhancements
to existing warnings".
To build it with GCC 11.1.0, one must add the flag: -Wno-stringop-overflow
when doing ./configure.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #52428:  SV-60798-Rework-to-silence-GCC11-warning.patch added by jwitteveen (4KiB - text/x-patch - Improved version of file #52425. Complements file #52422.)
file #52425:  SV-60798-Rework-to-silence-GCC11-warning.patch added by jwitteveen (3KiB - text/x-patch - Patch tested on Arch linux. Complements file #52422.)
file #52422:  SV-60798-Silence-bogus-GCC10-and-GCC11-warnings.patch added by jwitteveen (4KiB - text/x-patch - Patch tested on Arch Linux. Supersedes file #52420.)
file #52420:  SV-60798-Silence-bogus-GCC10-stringop-overflow-warni.patch added by jwitteveen (3KiB - text/x-patch - Patch tested on Arch Linux)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwitteveen (Updated the item)
  • -email is unavailable- added by psmith (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-12-19 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Fixed ReleaseNone 4.4
        Triage StatusNone Small Effort
    2021-12-04 jwitteveen Attached File- Added SV-60798-Rework-to-silence-GCC11-warning.patch, #52428
    2021-12-04 jwitteveen Attached File- Added SV-60798-Rework-to-silence-GCC11-warning.patch, #52425
    2021-12-03 jwitteveen Attached File- Added SV-60798-Silence-bogus-GCC10-and-GCC11-warnings.patch, #52422
    2021-12-03 jwitteveen Attached File- Added SV-60798-Silence-bogus-GCC10-stringop-overflow-warni.patch, #52420

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code