From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26006 invoked by alias); 10 Jan 2014 09:19:11 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 25970 invoked by uid 48); 10 Jan 2014 09:19:07 -0000 From: "martin at netbsd dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/59749] New: unused warning not emited for unused static struct unles -save-temps is used Date: Fri, 10 Jan 2014 09:19:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.8.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: martin at netbsd dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-01/txt/msg01047.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59749 Bug ID: 59749 Summary: unused warning not emited for unused static struct unles -save-temps is used Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: martin at netbsd dot org Created attachment 31793 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31793&action=edit original source file exhibiting the problem I have a program (for the atf testing framework) that is supposed to warn about an unused variable and (due to -Werror) fail compilation. This works fine with gcc 4.5.4. But with 4.8.2 I get: $ /usr/pkg/gcc48/bin/cc -O2 -c -Wall -Werror /usr/tests/atf/atf-c/unused_test.c $ The code (after macro expansion) declares a struct and initialize it: static atfu_this_is_unused_tc_pack = { .m_ident = .... }; and there is no reference to this struct anywhere in the file. Interestingly when preparing for this ticket I did: $ /usr/pkg/gcc48/bin/cc -O2 -save-temps -c -Wall -Werror /usr/tests/atf/atf-c/unused_test.c /usr/tests/atf/atf-c/unused_test.c:41:123: error: 'atfu_this_is_unused_tc' defined but not used [-Werror=unused-variable] ATF_TC(this_is_unused); ^ cc1: all warnings being treated as errors $ /usr/pkg/gcc48/bin/cc -v Using built-in specs. COLLECT_GCC=/usr/pkg/gcc48/bin/cc COLLECT_LTO_WRAPPER=/usr/pkg/gcc48/libexec/gcc/sparc64--netbsd/4.8.2/lto-wrapper Target: sparc64--netbsd Configured with: ../gcc-4.8.2/configure --enable-languages='c c++' --enable-shared --enable-long-long --with-local-prefix=/usr/pkg/gcc48 --enable-libssp --enable-threads=posix --with-boot-ldflags='-static-libstdc++ -static-libgcc -Wl,-R/usr/pkg/lib ' --with-gnu-ld --with-ld=/usr/bin/ld --with-gnu-as --with-as=/usr/bin/as --disable-nls --with-gmp=/usr/pkg --with-mpc=/usr/pkg --with-mpfr=/usr/pkg --enable-__cxa_atexit --with-gxx-include-dir=/usr/pkg/gcc48/include/c++/ --prefix=/usr/pkg/gcc48 --build=sparc64--netbsd --host=sparc64--netbsd --infodir=/usr/pkg/gcc48/info --mandir=/usr/pkg/gcc48/man Thread model: posix gcc version 4.8.2 (GCC)