public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95825] New: [7/8/9/10/11 Regression] boost::optional -Wuninitialized
@ 2020-06-22 19:31 nok.raven at gmail dot com
2020-06-23 6:58 ` [Bug c++/95825] [8/9/10/11 " rguenth at gcc dot gnu.org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: nok.raven at gmail dot com @ 2020-06-22 19:31 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95825
Bug ID: 95825
Summary: [7/8/9/10/11 Regression] boost::optional
-Wuninitialized
Product: gcc
Version: 10.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: nok.raven at gmail dot com
Target Milestone: ---
#include <boost/optional.hpp>
boost::optional<char> get()
{
return {};
}
boost::optional<char> foo()
{
return get();
}
// g++ -O3 -Wall -Wextra -fsanitize=address
<source>: In function 'boost::optional<char> foo()':
<source>:5:11: warning:
'<anonymous>.boost::optional<char>::<anonymous>.boost::optional_detail::tc_optional_base<char>::m_storage'
is used uninitialized in this function [-Wuninitialized]
5 | return {};
| ^
https://godbolt.org/z/PD_qan
Most likely related to bug 86465
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c++/95825] [8/9/10/11 Regression] boost::optional -Wuninitialized
2020-06-22 19:31 [Bug c++/95825] New: [7/8/9/10/11 Regression] boost::optional -Wuninitialized nok.raven at gmail dot com
@ 2020-06-23 6:58 ` rguenth at gcc dot gnu.org
2020-08-04 16:51 ` [Bug tree-optimization/95825] " mpolacek at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-06-23 6:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95825
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[7/8/9/10/11 Regression] |[8/9/10/11 Regression]
|boost::optional |boost::optional
|-Wuninitialized |-Wuninitialized
Target Milestone|--- |8.5
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/95825] [8/9/10/11 Regression] boost::optional -Wuninitialized
2020-06-22 19:31 [Bug c++/95825] New: [7/8/9/10/11 Regression] boost::optional -Wuninitialized nok.raven at gmail dot com
2020-06-23 6:58 ` [Bug c++/95825] [8/9/10/11 " rguenth at gcc dot gnu.org
@ 2020-08-04 16:51 ` mpolacek at gcc dot gnu.org
2020-10-12 12:53 ` rguenth at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2020-08-04 16:51 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95825
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-08-04
CC| |mpolacek at gcc dot gnu.org
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Component|c++ |tree-optimization
--- Comment #1 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
Started with r245840, not a C++ issue.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/95825] [8/9/10/11 Regression] boost::optional -Wuninitialized
2020-06-22 19:31 [Bug c++/95825] New: [7/8/9/10/11 Regression] boost::optional -Wuninitialized nok.raven at gmail dot com
2020-06-23 6:58 ` [Bug c++/95825] [8/9/10/11 " rguenth at gcc dot gnu.org
2020-08-04 16:51 ` [Bug tree-optimization/95825] " mpolacek at gcc dot gnu.org
@ 2020-10-12 12:53 ` rguenth at gcc dot gnu.org
2021-05-14 9:53 ` [Bug tree-optimization/95825] [9/10/11/12 " jakub at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-10-12 12:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95825
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/95825] [9/10/11/12 Regression] boost::optional -Wuninitialized
2020-06-22 19:31 [Bug c++/95825] New: [7/8/9/10/11 Regression] boost::optional -Wuninitialized nok.raven at gmail dot com
` (2 preceding siblings ...)
2020-10-12 12:53 ` rguenth at gcc dot gnu.org
@ 2021-05-14 9:53 ` jakub at gcc dot gnu.org
2021-06-01 8:17 ` rguenth at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-05-14 9:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95825
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|8.5 |9.4
--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 8 branch is being closed.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/95825] [9/10/11/12 Regression] boost::optional -Wuninitialized
2020-06-22 19:31 [Bug c++/95825] New: [7/8/9/10/11 Regression] boost::optional -Wuninitialized nok.raven at gmail dot com
` (3 preceding siblings ...)
2021-05-14 9:53 ` [Bug tree-optimization/95825] [9/10/11/12 " jakub at gcc dot gnu.org
@ 2021-06-01 8:17 ` rguenth at gcc dot gnu.org
2022-05-27 9:42 ` [Bug tree-optimization/95825] [10/11/12/13 " rguenth at gcc dot gnu.org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-06-01 8:17 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95825
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|9.4 |9.5
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/95825] [10/11/12/13 Regression] boost::optional -Wuninitialized
2020-06-22 19:31 [Bug c++/95825] New: [7/8/9/10/11 Regression] boost::optional -Wuninitialized nok.raven at gmail dot com
` (4 preceding siblings ...)
2021-06-01 8:17 ` rguenth at gcc dot gnu.org
@ 2022-05-27 9:42 ` rguenth at gcc dot gnu.org
2022-06-28 10:41 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27 9:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95825
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|9.5 |10.4
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/95825] [10/11/12/13 Regression] boost::optional -Wuninitialized
2020-06-22 19:31 [Bug c++/95825] New: [7/8/9/10/11 Regression] boost::optional -Wuninitialized nok.raven at gmail dot com
` (5 preceding siblings ...)
2022-05-27 9:42 ` [Bug tree-optimization/95825] [10/11/12/13 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:41 ` jakub at gcc dot gnu.org
2022-09-22 13:13 ` [Bug tree-optimization/95825] [10/11/12/13 Regression] boost::optional -Wuninitialized with -fsanitize=address rguenth at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95825
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.4 |10.5
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/95825] [10/11/12/13 Regression] boost::optional -Wuninitialized with -fsanitize=address
2020-06-22 19:31 [Bug c++/95825] New: [7/8/9/10/11 Regression] boost::optional -Wuninitialized nok.raven at gmail dot com
` (6 preceding siblings ...)
2022-06-28 10:41 ` jakub at gcc dot gnu.org
@ 2022-09-22 13:13 ` rguenth at gcc dot gnu.org
2023-04-17 8:15 ` daniel.klauer at gin dot de
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-09-22 13:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95825
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[10/11/12/13 Regression] |[10/11/12/13 Regression]
|boost::optional |boost::optional
|-Wuninitialized |-Wuninitialized with
| |-fsanitize=address
Last reconfirmed|2020-08-04 00:00:00 |2022-9-22
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
requires -fsanitize=address
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/95825] [10/11/12/13 Regression] boost::optional -Wuninitialized with -fsanitize=address
2020-06-22 19:31 [Bug c++/95825] New: [7/8/9/10/11 Regression] boost::optional -Wuninitialized nok.raven at gmail dot com
` (7 preceding siblings ...)
2022-09-22 13:13 ` [Bug tree-optimization/95825] [10/11/12/13 Regression] boost::optional -Wuninitialized with -fsanitize=address rguenth at gcc dot gnu.org
@ 2023-04-17 8:15 ` daniel.klauer at gin dot de
2023-04-17 8:22 ` daniel.kruegler at googlemail dot com
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: daniel.klauer at gin dot de @ 2023-04-17 8:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95825
daniel.klauer at gin dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |daniel.klauer at gin dot de
--- Comment #7 from daniel.klauer at gin dot de ---
Reduced test case:
template<typename T>
struct tc_optional_base
{
// default ctor leaves m_storage uninitialized
tc_optional_base() : m_initialized(false) {}
bool m_initialized;
T m_storage;
};
template<typename T>
tc_optional_base<T> f()
{
return {};
}
tc_optional_base<int> g()
{
return f<int>();
}
$ g++ -Wall -O1 -fsanitize=address b.cxx -c
In function ‘tc_optional_base<T> f() [with T = int]’,
inlined from ‘tc_optional_base<int> g()’ at b.cxx:18:15:
b.cxx:13:17: warning: ‘<anonymous>.tc_optional_base<int>::m_storage’ is used
uninitialized [-Wuninitialized]
13 | return {};
| ^
b.cxx: In function ‘tc_optional_base<int> g()’:
b.cxx:13:17: note: ‘<anonymous>’ declared here
13 | return {};
|
$ g++ --version
g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
It looks like the m_storage field really is uninitialized, although I think in
practice boost::optional does not access it in that state in its implementation
thanks to m_initialized. Does gcc warn about the uninitialized data during
copying of the object here? It does seem to be correct...
In the above case with templates it happens at -O1 already, but without
templates it happens too, at -O2.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/95825] [10/11/12/13 Regression] boost::optional -Wuninitialized with -fsanitize=address
2020-06-22 19:31 [Bug c++/95825] New: [7/8/9/10/11 Regression] boost::optional -Wuninitialized nok.raven at gmail dot com
` (8 preceding siblings ...)
2023-04-17 8:15 ` daniel.klauer at gin dot de
@ 2023-04-17 8:22 ` daniel.kruegler at googlemail dot com
2023-04-17 8:46 ` daniel.klauer at gin dot de
2023-07-07 10:37 ` [Bug tree-optimization/95825] [11/12/13/14 " rguenth at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2023-04-17 8:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95825
--- Comment #8 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
(In reply to daniel.klauer from comment #7)
> Reduced test case:
>
>
> template<typename T>
> struct tc_optional_base
> {
> // default ctor leaves m_storage uninitialized
> tc_optional_base() : m_initialized(false) {}
> bool m_initialized;
> T m_storage;
> };
This example seems unrelated to the issue, because you have here a struct, not
a union.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/95825] [10/11/12/13 Regression] boost::optional -Wuninitialized with -fsanitize=address
2020-06-22 19:31 [Bug c++/95825] New: [7/8/9/10/11 Regression] boost::optional -Wuninitialized nok.raven at gmail dot com
` (9 preceding siblings ...)
2023-04-17 8:22 ` daniel.kruegler at googlemail dot com
@ 2023-04-17 8:46 ` daniel.klauer at gin dot de
2023-07-07 10:37 ` [Bug tree-optimization/95825] [11/12/13/14 " rguenth at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: daniel.klauer at gin dot de @ 2023-04-17 8:46 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95825
--- Comment #9 from daniel.klauer at gin dot de ---
Unless I'm missing something, this is not about unions. boost::optional (at
least from boost 1.80.0) does not always use unions; instead it has two
possible implementations: optional_base, which uses unions, and
tc_optional_base, which does not. The original test case triggers the
tc_optional_base case too.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug tree-optimization/95825] [11/12/13/14 Regression] boost::optional -Wuninitialized with -fsanitize=address
2020-06-22 19:31 [Bug c++/95825] New: [7/8/9/10/11 Regression] boost::optional -Wuninitialized nok.raven at gmail dot com
` (10 preceding siblings ...)
2023-04-17 8:46 ` daniel.klauer at gin dot de
@ 2023-07-07 10:37 ` rguenth at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:37 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95825
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|10.5 |11.5
--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-07-07 10:37 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-22 19:31 [Bug c++/95825] New: [7/8/9/10/11 Regression] boost::optional -Wuninitialized nok.raven at gmail dot com
2020-06-23 6:58 ` [Bug c++/95825] [8/9/10/11 " rguenth at gcc dot gnu.org
2020-08-04 16:51 ` [Bug tree-optimization/95825] " mpolacek at gcc dot gnu.org
2020-10-12 12:53 ` rguenth at gcc dot gnu.org
2021-05-14 9:53 ` [Bug tree-optimization/95825] [9/10/11/12 " jakub at gcc dot gnu.org
2021-06-01 8:17 ` rguenth at gcc dot gnu.org
2022-05-27 9:42 ` [Bug tree-optimization/95825] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:41 ` jakub at gcc dot gnu.org
2022-09-22 13:13 ` [Bug tree-optimization/95825] [10/11/12/13 Regression] boost::optional -Wuninitialized with -fsanitize=address rguenth at gcc dot gnu.org
2023-04-17 8:15 ` daniel.klauer at gin dot de
2023-04-17 8:22 ` daniel.kruegler at googlemail dot com
2023-04-17 8:46 ` daniel.klauer at gin dot de
2023-07-07 10:37 ` [Bug tree-optimization/95825] [11/12/13/14 " 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).