wrong "maybe-uninitialized" warning with -O3 (when building goplay)

Bug #1521081 reported by Martin Pitt
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-5 (Ubuntu)
New
Undecided
Unassigned

Bug Description

goplay FTBFS on ppc64el with:

g++ -DHAVE_CONFIG_H -I. -I.. -I.. -I/usr/include/tagcoll-2.0.14 -Wall -Werror -ggdb -g -O3 -fstack-protector-strong -Wformat -Werror=format-security -std=c++11 -c -o XDGDesktopEntry.o XDGDesktopEntry.cpp
XDGDesktopEntry.cpp: In member function 'int XDGDesktopEntry::run(const char*)':
XDGDesktopEntry.cpp:655:17: error: 'value' may be used uninitialized in this function [-Werror=maybe-uninitialized]
      if (value[i] == 'i') {
                 ^
cc1plus: all warnings being treated as errors

full build log: https://launchpadlibrarian.net/227946515/buildlog_ubuntu-xenial-ppc64el.goplay_0.9.1%2Bnmu1_BUILDING.txt.gz

This does not make much sense to me. The code:

    // Now run the desktop file
    getEntry("Exec", NULL, &value);

    // XXX: For now, just remove the field codes...
    std::string commandString;
    for(unsigned int i = 0; value[i] != '\0'; i++) {
       if (value[i] == '%') {
             i++;
             if (value[i] == 'i') {

value is a "const char*" and gets initialized in the getEntry(). Even *if* there was a reason to argue that value might be uninitialized, then the complaint should already be for the "for" loop. There is no reason why value should be valid in the "for" loop and for the "value[i] == '%'" check, but after incrementing just "i" it would suddenly not be any more.

It builds fine on Debian ppc64el (https://buildd.debian.org/status/fetch.php?pkg=goplay&arch=ppc64el&ver=0.9.1%2Bnmu1&stamp=1448818386) and on all other Ubuntu architectures. So this seems to be specific to gcc-5 on Ubuntu on ppc64el.

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: gcc-5 5.2.1-26ubuntu1
ProcVersionSignature: Ubuntu 4.2.0-19.23-generic 4.2.6
Uname: Linux 4.2.0-19-generic x86_64
ApportVersion: 2.19.2-0ubuntu8
Architecture: amd64
CurrentDesktop: Unity
Date: Mon Nov 30 08:19:47 2015
EcryptfsInUse: Yes
SourcePackage: gcc-5
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Martin Pitt (pitti) wrote :
Revision history for this message
Martin Pitt (pitti) wrote :

The previous version still built on ppc64el, and the affected code did not change there: https://launchpad.net/ubuntu/+source/goplay/0.9ubuntu1/+build/7778372 . That was with gcc-5 5.2.1-15ubuntu1.

Revision history for this message
Matthias Klose (doko) wrote :

I doubt this is ppc specific, but triggered by -O3 instead.

summary: - wrong "maybe-uninitialized" warning on ppc64el only (when building
- goplay)
+ wrong "maybe-uninitialized" warning with -O3 (when building goplay)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.