public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/51806] New: -flto ignores -Werror
@ 2012-01-10  1:28 DeusExSophismata at gmail dot com
  2012-01-10 10:04 ` [Bug lto/51806] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: DeusExSophismata at gmail dot com @ 2012-01-10  1:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51806

             Bug #: 51806
           Summary: -flto ignores -Werror
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: lto
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: DeusExSophismata@gmail.com


If a program triggers a warning that is only discovered during link time
optimization (such as a potential use of an uninitialized variable that crosses
compilation unit boundaries), the flag -Werror is ignored.

[david@david-desktop gcc error]$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.6.2/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-linker-build-id
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin
--enable-java-awt=gtk --disable-dssi
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 4.6.2 20111027 (Red Hat 4.6.2-1) (GCC) 


==============================================
main.cpp
==============================================
void f1 (int & x);

int main () {
    int x;
    f1 (x);
    return 0;
}
==============================================
werror.cpp
==============================================
void f1 (int & x) {
    volatile int y = x;
}
==============================================

[david@david-desktop gcc error]$ g++ main.cpp werror.cpp -Wuninitialized
-Werror -O1 -flto
In file included from :0:0:
main.cpp: In function ‘main’:
werror.cpp:2:19: warning: ‘x’ is used uninitialized in this function
[-Wuninitialized]
main.cpp:4:6: note: ‘x’ was declared here


Compilation is seen as successful and a.out exists.

The expected behavior is that the warning would be converted to an error by
-Werror and stop the linking / compiling final stage. The effect of this is
that automated build tools believe that the compiling was a success (and the
warning may be buried deep in the middle of the output when compiling multiple
programs), so the user may not know that there was a problem found despite
having -Werror selected.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug lto/51806] -flto ignores -Werror
  2012-01-10  1:28 [Bug lto/51806] New: -flto ignores -Werror DeusExSophismata at gmail dot com
@ 2012-01-10 10:04 ` rguenth at gcc dot gnu.org
  2012-01-10 16:29 ` rguenth at gcc dot gnu.org
  2012-01-10 16:32 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-01-10 10:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51806

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2012-01-10
                 CC|                            |jsm28 at gcc dot gnu.org
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-10 10:03:17 UTC ---
Confirmed.  It seems that -Werror is a C-family frontend specific option,
despite being annotated as 'common'.  Only c_common_handle_option has

    case OPT_Werror:
      global_dc->warning_as_error_requested = value;
      break;

and thus properly adjusts the diagnostic machinery of the middle-end.
But -Werror=... seems to be handled fine (thus, in your case
-Werror=uninitialized).  That seems inconsistent at least.

It looks like the OPT_Werror handling above should move to common_handle_option
instead.  Joseph?


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug lto/51806] -flto ignores -Werror
  2012-01-10  1:28 [Bug lto/51806] New: -flto ignores -Werror DeusExSophismata at gmail dot com
  2012-01-10 10:04 ` [Bug lto/51806] " rguenth at gcc dot gnu.org
@ 2012-01-10 16:29 ` rguenth at gcc dot gnu.org
  2012-01-10 16:32 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-01-10 16:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51806

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-10 16:28:07 UTC ---
Author: rguenth
Date: Tue Jan 10 16:27:55 2012
New Revision: 183069

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=183069
Log:
2012-01-10  Richard Guenther  <rguenther@suse.de>

    PR middle-end/51806
    c-family/
    * c-opts.c (c_common_handle_option): Move -Werror handling
    to language independent code.

    * opts.c (common_handle_option): Handle -Werror.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-family/ChangeLog
    trunk/gcc/c-family/c-opts.c
    trunk/gcc/opts.c


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug lto/51806] -flto ignores -Werror
  2012-01-10  1:28 [Bug lto/51806] New: -flto ignores -Werror DeusExSophismata at gmail dot com
  2012-01-10 10:04 ` [Bug lto/51806] " rguenth at gcc dot gnu.org
  2012-01-10 16:29 ` rguenth at gcc dot gnu.org
@ 2012-01-10 16:32 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2012-01-10 16:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51806

Richard Guenther <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.0

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2012-01-10 16:31:09 UTC ---
Fixed for 4.7.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-10 16:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-10  1:28 [Bug lto/51806] New: -flto ignores -Werror DeusExSophismata at gmail dot com
2012-01-10 10:04 ` [Bug lto/51806] " rguenth at gcc dot gnu.org
2012-01-10 16:29 ` rguenth at gcc dot gnu.org
2012-01-10 16:32 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).