public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59800] New: Compilation with g++ fails when -Ofast -flto is used to compile code using some <random> distribution
@ 2014-01-14  6:01 rionda at gmail dot com
  2014-01-14 12:05 ` [Bug c++/59800] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: rionda at gmail dot com @ 2014-01-14  6:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59800
           Summary: Compilation with g++ fails when -Ofast -flto is used
                    to compile code using some <random> distribution
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rionda at gmail dot com

Created attachment 31828
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31828&action=edit
Code that fails

The attached code compiles cleanly when using 
g++ -Ofast -Wall -Wextra -Wno-unused-parameter test.cpp test.cpp
and when using
g++ -flto -Wall -Wextra -Wno-unused-parameter test.cpp
but fails when using "g++8 -std=c++11 -Ofast -flto -Wall -Wextra
-Wno-unused-parameter test.cpp" (i.e., when using both -Ofast and -flto).

The reported error is:
test.cpp: In function 'main':
/opt/local/include/gcc48/c++/bits/random.h:2404:60: warning: 'MEM[(struct
normal_distribution *)&my_lognormal + 16B]._M_saved' may be used uninitialized
in this function [-Wmaybe-uninitialized]
         { return std::exp(__p.s() * _M_nd(__urng) + __p.m()); }
                                                            ^
test.cpp:11:33: note: 'MEM[(struct normal_distribution *)&my_lognormal +
16B]._M_saved' was declared here
  lognormal_distribution<double> my_lognormal(0.0, 1.0);
                                 ^

I am running 
g++-mp-4.8 (MacPorts gcc48 4.8.2_0) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
on Mac OS X 10.6.8
(uname -a : darwin xxxx.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7
16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386)


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

* [Bug c++/59800] Compilation with g++ fails when -Ofast -flto is used to compile code using some <random> distribution
  2014-01-14  6:01 [Bug c++/59800] New: Compilation with g++ fails when -Ofast -flto is used to compile code using some <random> distribution rionda at gmail dot com
@ 2014-01-14 12:05 ` rguenth at gcc dot gnu.org
  2014-07-09 19:52 ` rionda at gmail dot com
  2014-07-09 20:49 ` manu at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-01-14 12:05 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2014-01-14
     Ever confirmed|0                           |1

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
That's not an error but a warning?!  Anyway, it's triggered by
-Wmaybe-uninitialized.

Also happens on trunk.


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

* [Bug c++/59800] Compilation with g++ fails when -Ofast -flto is used to compile code using some <random> distribution
  2014-01-14  6:01 [Bug c++/59800] New: Compilation with g++ fails when -Ofast -flto is used to compile code using some <random> distribution rionda at gmail dot com
  2014-01-14 12:05 ` [Bug c++/59800] " rguenth at gcc dot gnu.org
@ 2014-07-09 19:52 ` rionda at gmail dot com
  2014-07-09 20:49 ` manu at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rionda at gmail dot com @ 2014-07-09 19:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59800

--- Comment #3 from Matteo Riondato <rionda at gmail dot com> ---
What exactly does the "WAITING" status mean?


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

* [Bug c++/59800] Compilation with g++ fails when -Ofast -flto is used to compile code using some <random> distribution
  2014-01-14  6:01 [Bug c++/59800] New: Compilation with g++ fails when -Ofast -flto is used to compile code using some <random> distribution rionda at gmail dot com
  2014-01-14 12:05 ` [Bug c++/59800] " rguenth at gcc dot gnu.org
  2014-07-09 19:52 ` rionda at gmail dot com
@ 2014-07-09 20:49 ` manu at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: manu at gcc dot gnu.org @ 2014-07-09 20:49 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59800

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW
                 CC|                            |manu at gcc dot gnu.org

--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
The meaning is explained here: https://gcc.gnu.org/bugs/management.html
but I think it was a slip in this case.

Probably the uninit pass is not powerful enough, but in this case the warning
should be suppressed for system-headers:

manuel@gcc10:~$ ~/test1/210581/install/bin/g++ -std=c++11  -O2 -Wsystem-headers
-Wmaybe-uninitialized test.cc
In file included from
/home/manuel/test1/210581/install/include/c++/4.10.0/random:51:0,
                 from test.cc:3:
/home/manuel/test1/210581/install/include/c++/4.10.0/bits/random.tcc: In
function ‘int main(int, char**)’:
/home/manuel/test1/210581/install/include/c++/4.10.0/bits/random.tcc:1964:2:
warning: ‘*((void*)(&
my_lognormal)+16).std::normal_distribution<double>::_M_saved’ may be used
uninitialized in this function [-Wmaybe-uninitialized]
  __ret = __ret * __param.stddev() + __param.mean();
  ^
test.cc:11:33: note: ‘*((void*)(&
my_lognormal)+16).std::normal_distribution<double>::_M_saved’ was declared here
  lognormal_distribution<double> my_lognormal(0.0, 1.0);
                                 ^

and -flto bypassed the system_header pragma somehow.
>From gcc-bugs-return-455988-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Jul 09 21:13:16 2014
Return-Path: <gcc-bugs-return-455988-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 7056 invoked by alias); 9 Jul 2014 21:13:15 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 6992 invoked by uid 48); 9 Jul 2014 21:13:08 -0000
From: "unmobile at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/46097] Switch to warn of global variables in a C++ shared object
Date: Wed, 09 Jul 2014 21:13:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: unmobile at gmail dot com
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: cc
Message-ID: <bug-46097-4-Azb56Kd1MM@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-46097-4@http.gcc.gnu.org/bugzilla/>
References: <bug-46097-4@http.gcc.gnu.org/bugzilla/>
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-07/txt/msg00579.txt.bz2
Content-length: 950

https://gcc.gnu.org/bugzilla/show_bug.cgi?idF097

Phil Miller <unmobile at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |unmobile at gmail dot com

--- Comment #32 from Phil Miller <unmobile at gmail dot com> ---
A switch to generate warnings about global variables would be useful to me and
my colleagues (http://ppl.cs.illinois.edu/) for a reason totally distinct from
ODR violations. We have a parallel programming system that includes a feature
for running application code in multiple, nominally independent, user-level
threads within a process. A mechanism to call attention to code that may fail
or misbehave in this setting would be helpful.

I would definitely agree that this doesn't belong in -Wall or -Wextra, as such.
So a -fnote-global-variables might be more appropriate.


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

end of thread, other threads:[~2014-07-09 20:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-14  6:01 [Bug c++/59800] New: Compilation with g++ fails when -Ofast -flto is used to compile code using some <random> distribution rionda at gmail dot com
2014-01-14 12:05 ` [Bug c++/59800] " rguenth at gcc dot gnu.org
2014-07-09 19:52 ` rionda at gmail dot com
2014-07-09 20:49 ` manu 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).