From: Sergei Trofimovich <slyfox@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev] Changing policy about -Werror
Date: Sat, 15 Sep 2018 00:07:53 +0100 [thread overview]
Message-ID: <20180915000753.19a8715f@sf> (raw)
In-Reply-To: <B1C5D954-0267-4E42-9C37-62D7B512BF37@gentoo.org>
On Fri, 14 Sep 2018 11:54:57 -0400
Richard Yao <ryao@gentoo.org> wrote:
> >> My read of this is that the warning occurs regardless of optimization level, but it could somehow be improved by optimization.
> >>
> >> As for the last, it is for uninitialized variable reads. However, I think you are misinterpreting the claim. The way that optimization level could affect warning generation would be if the warning generation came after optimization passes that could hide reads. That means that -O3 would prevent the warning.
...
> Either provide code examples that generate warnings in a way that demonstrates that I am incorrect
To make code behave differently it needs substantial amount of code
to provide you an example. You need to him O2<->O3 behaviour delta
after all. But I will try (for a different warning, it should not matter
much).
Below is a reduced example of a larger C++ program.
Many thanks to Ulya for providing recent example!
In this example -O3 manages to inline/const-propagate deep enough
and find out potential null-deref. -O2 was not able to do it.
$ bash -x ./mk_.sh
+ LANG=C
+ g++-8.2.0 -O2 -c 1.cc -Wnull-dereference
+ g++-8.2.0 -O3 -c 1.cc -Wnull-dereference
1.cc: In function 'bool foo(std::vector<int>)':
1.cc:3:22: warning: null pointer dereference [-Wnull-dereference]
typename h = e - d >> *g;
~~~~~~^~~~~
1.cc:3:22: warning: null pointer dereference [-Wnull-dereference]
typename h = e - d >> *g;
~~~~~~^~~~~
$ cat 1.cc
#include <vector>
template <typename a, typename b> a c(a d, a e, b f, int *g) {
typename h = e - d >> *g;
for (; h;) if (f(*d)) if (f(*d)) return d;
return d;
}
template <typename i, typename b> i o(i d, i e, b f, int *g) {
return c(d, e, f, g);
}
template <typename i, typename b> i oo(i d, i e, b f, int *g) {
return c(d, e, f, g);
}
template <typename j, typename b> j k(j d, j e, b f, int *g) {
return o(d, e, f, g);
}
template <typename j, typename b> j kk(j d, j e, b f, int *g) {
return oo(d, e, f, g);
}
bool cmpp(int);
bool foo(std::vector<int> l) {
std::vector<int>::const_iterator ib,
ie = l.end(), m, n = k(ib, ie, cmpp, 0) = kk(m, ie, cmpp, 0);
return m == n;
}
--
Sergei
next prev parent reply other threads:[~2018-09-14 23:08 UTC|newest]
Thread overview: 119+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-09 11:32 [gentoo-dev] Changing policy about -Werror Andrew Savchenko
2018-09-09 13:03 ` Thomas Deutschmann
2018-09-09 15:02 ` Andrew Savchenko
2018-09-09 16:32 ` Ulrich Mueller
2018-09-09 17:18 ` Richard Yao
2018-09-09 15:11 ` Jeroen Roovers
2018-09-09 15:22 ` Richard Yao
2018-09-09 16:11 ` Michał Górny
2018-09-09 17:09 ` Richard Yao
2018-09-09 17:24 ` Richard Yao
2018-09-09 17:13 ` Richard Yao
2018-09-12 20:28 ` Andreas K. Huettel
2018-09-12 21:54 ` Richard Yao
2018-09-10 14:19 ` Fabian Groffen
2018-09-10 21:18 ` Chí-Thanh Christopher Nguyễn
2018-09-10 21:44 ` Richard Yao
2018-09-10 21:42 ` Richard Yao
2018-09-09 16:31 ` Michał Górny
2018-09-09 23:46 ` Chí-Thanh Christopher Nguyễn
2018-09-10 7:45 ` Jason Zaman
2018-09-10 20:34 ` Chí-Thanh Christopher Nguyễn
2018-09-10 20:51 ` Matt Turner
2018-09-10 20:56 ` Kristian Fiskerstrand
2018-09-10 20:59 ` Mart Raudsepp
2018-09-10 21:26 ` Chí-Thanh Christopher Nguyễn
2018-09-10 21:43 ` Richard Yao
2018-09-10 21:01 ` Kristian Fiskerstrand
2018-09-10 21:01 ` Mike Gilbert
2018-09-10 21:04 ` Kristian Fiskerstrand
2018-09-10 21:10 ` Kristian Fiskerstrand
2018-09-11 0:50 ` Thomas Deutschmann
2018-09-10 21:31 ` Rich Freeman
2018-09-10 21:33 ` Kristian Fiskerstrand
2018-09-10 21:58 ` Mike Gilbert
2018-09-10 21:19 ` Chí-Thanh Christopher Nguyễn
2018-09-10 21:21 ` Kristian Fiskerstrand
2018-09-10 21:27 ` Kristian Fiskerstrand
2018-09-10 21:48 ` Richard Yao
2018-09-10 21:52 ` Richard Yao
2018-09-10 21:35 ` Chí-Thanh Christopher Nguyễn
2018-09-10 21:41 ` Kristian Fiskerstrand
2018-09-12 8:56 ` Jason Zaman
2018-09-12 14:50 ` Rich Freeman
2018-09-12 16:47 ` Mike
2018-09-13 11:25 ` Ulrich Mueller
2018-09-13 13:29 ` Mike
2018-09-13 13:35 ` Rich Freeman
2018-09-13 13:39 ` Mike
2018-09-13 14:06 ` Ulrich Mueller
2018-09-12 22:55 ` Thomas Deutschmann
2018-09-12 23:03 ` Rich Freeman
2018-09-12 23:52 ` Matt Turner
2018-09-13 0:11 ` Rich Freeman
2018-09-13 0:46 ` Matt Turner
2018-09-13 15:51 ` Fabian Groffen
2018-09-13 15:56 ` Alon Bar-Lev
2018-09-13 16:20 ` Fabian Groffen
2018-09-13 17:58 ` Alon Bar-Lev
2018-09-14 0:41 ` Georg Rudoy
2018-09-12 23:47 ` Chí-Thanh Christopher Nguyễn
2018-09-13 11:36 ` Richard Yao
2018-09-13 16:03 ` Fabian Groffen
2018-09-13 23:12 ` Richard Yao
2018-09-13 23:21 ` Matt Turner
2018-09-14 0:44 ` Richard Yao
2018-09-14 0:54 ` Georg Rudoy
2018-09-14 17:09 ` Richard Yao
2018-09-14 3:35 ` Matt Turner
2018-09-14 15:54 ` Richard Yao
2018-09-14 23:07 ` Sergei Trofimovich [this message]
2018-09-14 23:27 ` Richard Yao
2018-09-21 22:33 ` Chí-Thanh Christopher Nguyễn
2018-09-22 5:57 ` Alon Bar-Lev
2018-09-14 17:47 ` Richard Yao
2018-09-14 17:58 ` Richard Yao
2018-09-13 15:48 ` Fabian Groffen
2018-09-09 17:50 ` Michael Orlitzky
2018-09-10 0:30 ` Rich Freeman
2018-09-09 20:47 ` Matt Turner
2018-09-10 0:13 ` Chí-Thanh Christopher Nguyễn
2018-09-11 6:15 ` Andreas K. Huettel
2018-09-11 9:44 ` Alon Bar-Lev
2018-09-12 23:32 ` Chí-Thanh Christopher Nguyễn
2018-09-13 0:09 ` Rich Freeman
2018-09-13 16:07 ` Fabian Groffen
2018-09-13 21:34 ` Sergei Trofimovich
2018-09-14 16:40 ` Alon Bar-Lev
2018-09-14 17:16 ` Richard Yao
2018-09-14 17:22 ` Alon Bar-Lev
2018-09-14 17:26 ` Rich Freeman
2018-09-14 17:33 ` Michał Górny
2018-09-14 17:48 ` Alon Bar-Lev
2018-09-14 17:53 ` Michał Górny
2018-09-14 18:00 ` Alon Bar-Lev
2018-09-14 17:52 ` Rich Freeman
2018-09-14 19:29 ` Michael Orlitzky
2018-09-14 19:58 ` Richard Yao
2018-09-14 20:20 ` Michael Orlitzky
2018-09-14 20:29 ` Rich Freeman
2018-09-14 21:02 ` Fabian Groffen
2018-09-14 21:07 ` Alon Bar-Lev
2018-09-14 21:28 ` Fabian Groffen
2018-09-14 21:46 ` Alon Bar-Lev
2018-09-14 22:45 ` Fabian Groffen
2018-09-14 22:14 ` Richard Yao
2018-09-14 22:58 ` Alon Bar-Lev
2018-09-14 22:11 ` Richard Yao
2018-09-14 19:53 ` Sergei Trofimovich
2018-09-14 20:15 ` Alon Bar-Lev
2018-09-14 23:43 ` Sergei Trofimovich
2018-09-12 23:35 ` [gentoo-dev] acceptable alternatives to -Werror, was: " Chí-Thanh Christopher Nguyễn
2018-09-13 0:14 ` Rich Freeman
2018-09-13 0:23 ` Chí-Thanh Christopher Nguyễn
2018-09-13 0:34 ` Rich Freeman
2018-09-13 0:43 ` Chí-Thanh Christopher Nguyễn
2018-09-13 8:49 ` Mike Auty
2018-09-21 22:42 ` Chí-Thanh Christopher Nguyễn
2018-09-13 11:47 ` Richard Yao
2018-09-13 19:32 ` [gentoo-dev] " Nikos Chantziaras
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180915000753.19a8715f@sf \
--to=slyfox@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox