[Bug 230189] New: gcc shouldn't warn when testing two distinct string literals for equality
https://bugzilla.novell.com/show_bug.cgi?id=230189 Summary: gcc shouldn't warn when testing two distinct string literals for equality Product: openSUSE 10.3 Version: unspecified Platform: Other OS/Version: Other Status: NEW Severity: Minor Priority: P5 - None Component: Development AssignedTo: rguenther@novell.com ReportedBy: mmarek@novell.com QAContact: qa@suse.de $ cat cmp.c int f1(void) { return "string1" == "string2"; } int f2(void) { return "string3" != "string4"; } $ gcc -c -Wall cmp.c cmp.c: In function ‘f1’: cmp.c:3: warning: comparison with string literal cmp.c: In function ‘f2’: cmp.c:8: warning: comparison with string literal $ Not that code like this would fall into the category "good programming practice", but the expressions will work nevertheless. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=230189 ------- Comment #1 from mmarek@novell.com 2006-12-21 05:18 MST ------- Created an attachment (id=110675) --> (https://bugzilla.novell.com/attachment.cgi?id=110675&action=view) _untested_ patch for C -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=230189 ------- Comment #2 from mmarek@novell.com 2006-12-28 05:45 MST ------- (In reply to comment #1)
Created an attachment (id=110675) --> (https://bugzilla.novell.com/attachment.cgi?id=110675&action=view) [edit] _untested_ patch for C
Doesn't work :-/ -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=230189 rguenther@novell.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #3 from rguenther@novell.com 2007-01-14 10:34 MST ------- It is not guaranteed that "string1" == "string1" (they are not required to be merged). So your program is not portable. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=230189 mmarek@novell.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID | ------- Comment #4 from mmarek@novell.com 2007-01-14 12:14 MST ------- In the example above, there are four _different_ strings, which will live at four different addresses. Of course if fixing this is too difficult, then feel free to close this again. Code like this isn't very common... -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
https://bugzilla.novell.com/show_bug.cgi?id=230189 rguenther@novell.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|REOPENED |RESOLVED Resolution| |INVALID ------- Comment #5 from rguenther@novell.com 2007-01-15 06:10 MST ------- The point I wanted to make is that comparison of string literals is pointless, so the warning is ok. I guess you want to avoid the warning if we can prove the result will be the same regardless of whether string literals are merged? If so, please file this upstream as an enhancement request or with fate. Thanks, Richard. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.
participants (1)
-
bugzilla_noreply@novell.com