Bug 663080 - gcc thinks differently about array bounds between x86_64 and s390x
Summary: gcc thinks differently about array bounds between x86_64 and s390x
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: 19
Hardware: s390x
OS: Linux
low
medium
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-12-14 16:16 UTC by Dan Horák
Modified: 2014-08-26 17:06 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-08-26 17:06:22 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
preprocessed source (425.21 KB, application/octet-stream)
2010-12-14 16:16 UTC, Dan Horák
no flags Details

Description Dan Horák 2010-12-14 16:16:24 UTC
Created attachment 468636 [details]
preprocessed source

code snippet from tools/perf/util/ui/browser.c

...
void ui_browser__add_exit_keys(struct ui_browser *self, int keys[])
{
        int i = 0;

        while (keys[i] && i < 64) {
                ui_browser__add_exit_key(self, keys[i]);
                ++i;
        }
}
        
int ui_browser__show(struct ui_browser *self, const char *title,
                     const char *helpline, ...)
{
        va_list ap;
        int keys[] = { NEWT_KEY_UP, NEWT_KEY_DOWN, NEWT_KEY_PGUP,
                       NEWT_KEY_PGDN, NEWT_KEY_HOME, NEWT_KEY_END, ' ',
                       NEWT_KEY_LEFT, NEWT_KEY_ESCAPE, 'q', CTRL('c'), 0 };

        if (self->form != NULL)
                newtFormDestroy(self->form);

        ui_browser__refresh_dimensions(self);
        self->form = newtForm(NULL, NULL, 0);
        if (self->form == NULL)
                return -1;

        self->sb = newtVerticalScrollbar(self->width, 1, self->height,
                                         HE_COLORSET_NORMAL,
                                         HE_COLORSET_SELECTED);
        if (self->sb == NULL)
                return -1;

        SLsmg_gotorc(0, 0);
        ui_browser__set_color(self, NEWT_COLORSET_ROOT);
        slsmg_write_nstring(title, self->width);

        ui_browser__add_exit_keys(self, keys);
        newtFormAddComponent(self->form, self->sb);

        va_start(ap, helpline);
        ui_helpline__vpush(helpline, ap);
        va_end(ap);
        return 0;
}
...

Compile on s390x fails with

gcc -o util/ui/browser.o -c -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Wformat-y2k -Wshadow -Winit-self -Wpacked -Wredundant-decls -Wstack-protector -Wstrict-aliasing=3 -Wswitch-default -Wswitch-enum -Wno-system-headers -Wundef -Wvolatile-register-var -Wwrite-strings -Wbad-function-cast -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wstrict-prototypes -Wdeclaration-after-statement  -fstack-protector-all -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Iutil/include -Iarch/s390/include -DLIBELF_NO_MMAP -I/usr/include/slang -DNO_STRLCPY -DSHA1_HEADER='<openssl/sha.h>'  -DENABLE_SLFUTURE_CONST util/ui/browser.c
cc1: warnings being treated as errors
util/ui/browser.c: In function ‘ui_browser__show’:
util/ui/browser.c:153:13: error: array subscript is above array bounds
...

while it compiles fine on x86_64, line 153 is the "while (keys[i] && i < 64)" condition

tested with  gcc-4.5.1-4 in F-14 and gcc-4.5.1-6 in koji

Comment 1 Dan Horák 2011-01-31 15:19:01 UTC
still present in gcc-4.6.0-0.5.fc15

Comment 2 Dan Horák 2011-09-08 17:28:01 UTC
and still present in gcc-4.6.1-7.fc16

Comment 3 Aravind vijayan 2011-11-12 18:39:02 UTC

-- 
Fedora Bugzappers volunteer triage team
https://fedoraproject.org/wiki/BugZappers

Comment 4 Fedora End Of Life 2013-04-03 18:37:34 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 19 development cycle.
Changing version to '19'.

(As we did not run this process for some time, it could affect also pre-Fedora 19 development
cycle bugs. We are very sorry. It will help us with cleanup during Fedora 19 End Of Life. Thank you.)

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora19

Comment 5 Dan Horák 2014-08-26 17:06:22 UTC
and not present in gcc 4.8 and 4.9, closing


Note You need to log in before you can comment on or make changes to this bug.