This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix -Os related -Werror failures.


On 10/28/2016 12:32 AM, Florian Weimer wrote:
On 10/28/2016 06:46 AM, Carlos O'Donell wrote:
+/* With GCC 5.3 when compiling with -Os the compiler emits a warning
+   that buf[0] and buf[1] may be used uninitialized.  This can only
+   happen in the case where tmpbuf[3] is used, and in that case the
+   write to the tmpbuf[1] and tmpbuf[2] was assured because
+   ucs4_to_cns11643 would have filled in those entries.  The difficulty
+   is in getting the compiler to see this logic because tmpbuf[0] is
+   involved in determining the code page and is the indicator that
+   tmpbuf[2] is initialized.  */
+DIAG_PUSH_NEEDS_COMMENT;
+DIAG_IGNORE_NEEDS_COMMENT (5.3, "-Wmaybe-uninitialized");

This hides the warning for -O2 builds as well, so I don't think this is
a good idea.

Those who want to build with -Os or other special compiler flags should
just configure with --disable-werror.  We can't account for every
optimization someone might want to disable in their build.
That'd be my recommendation.

What often happens in these cases is the compiler in its default mode of operation is able to statically eliminate a conditional branch on a particular path. However, to do so the compiler has to duplicate code.

Not surprisingly, there's a cost/benefit tradeoff here and the heuristics are largely driven by the real or estimated profile data as well as the coarser "optimize for code space". So changing flags changes the output of those heuristics and ultimately can result in leaving paths in the CFG that can not be executed -- and that often leads to false positive may-be-uninitialized warnings and such.

Long term I would like to find a good way to mark paths that are not executable, but are not profitable to eliminate, then utilize that information to prune various "may" warnings. That would make those kind of warnings more stable across different optimization levels as well as more stable release-to-release. But that's definitely in the "future work" area.

jeff


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]