Bug 492973

Summary: optimized strncmp macro creates odd warnings
Product: [Fedora] Fedora Reporter: Bill Nottingham <notting>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED DUPLICATE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: dcantrell, jakub, rvokal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-03-31 00:25:13 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Bill Nottingham 2009-03-31 00:19:44 UTC
[notting@nostromo: ~]$ cat foo.c
#include <stdio.h>
#include <string.h>

int main() {
        char *foo = "..";
        printf("%d\n", strncmp(foo, ".",1));
        return 0;
}
[notting@nostromo: ~]$ gcc -Wall -o foo foo.c  -O2
foo.c: In function ‘main’:
foo.c:6: warning: offset ‘3’ outside bounds of constant string

Turning off optimization (or parens around strncmp) fixes the warning.

Version-Release number of selected component (if applicable):

gcc-4.4.0-0.30.x86_64
glibc-devel-2.9.90-11.x86_64

How reproducible:

100%

Comment 1 Bill Nottingham 2009-03-31 00:25:13 UTC

*** This bug has been marked as a duplicate of bug 492846 ***