bugmake - Bugs: bug #66343, building with -Wstring-compare...

 
 

bug #66343: building with -Wstring-compare triggers severe warnings

Submitter:  None
Submitted:  Thu 17 Oct 2024 11:10:41 AM UTC
   
 
Severity:  3 - Normal Item Group:  Build/Install
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  4.4.1 Operating System:  POSIX-Based
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 17 Oct 2024 03:27:55 PM UTC, comment #1: 

These seem to be generated by using the streq() macro:

/* Test if two strings are equal. Is this worthwhile?  Should be profiled.  */
#define streq(a, b) \
   ((a) == (b) || \
    ((a) == (b) && (*(a) == '\0' || !strcmp ((a) + 1, (b) + 1))))

The pre-check for a == b may seem naive to the compiler but it's part of a reasonable optimization so maybe this warning can be pragma-ed out. OTOH the comment says it may be overkill so maybe the pre-checks are a waste of time anyway. For all I know a reasonable compiler may generate similar code for strcmp calls anyway, it's quite a stable and common function.

Anonymous
Thu 17 Oct 2024 11:10:41 AM UTC, original submission:  

attempting to build make with clang-17 -Wstring-compare triggers severe warnings:


 * src/main.c:872:11: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/main.c:874:16: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/main.c:876:16: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/main.c:878:16: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/main.c:1540:13: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/read.c:1902:30: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/read.c:1918:32: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/read.c:1925:25: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/read.c:1992:7: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/variable.c:411:47: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/variable.c:1142:33: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/variable.c:1146:29: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/variable.c:1153:33: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/variable.c:1166:37: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/variable.c:1194:34: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/variable.c:1251:7: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/variable.c:1254:12: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/variable.c:1421:21: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]
 * src/posixos.c:876:7: warning: result of comparison against a string literal is unspecified (use an explicit string comparison function instead) [-Wstring-compare]


Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

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.

 

No changes have been made to this item

Back to the top

Powered by Savane 3.15-e6e5.
Corresponding source code