public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-955@http.gcc.gnu.org/bugzilla/> @ 2006-03-01 19:02 ` pinskia at gcc dot gnu dot org 2006-03-01 23:01 ` joseph at codesourcery dot com ` (9 subsequent siblings) 10 siblings, 0 replies; 16+ messages in thread From: pinskia at gcc dot gnu dot org @ 2006-03-01 19:02 UTC (permalink / raw) To: gcc-bugs ------- Comment #12 from pinskia at gcc dot gnu dot org 2006-03-01 19:02 ------- *** Bug 26516 has been marked as a duplicate of this bug. *** -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |mnmoran at bellsouth dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-955@http.gcc.gnu.org/bugzilla/> 2006-03-01 19:02 ` [Bug middle-end/4210] should not warning with dead code pinskia at gcc dot gnu dot org @ 2006-03-01 23:01 ` joseph at codesourcery dot com 2006-03-01 23:05 ` bangerth at dealii dot org ` (8 subsequent siblings) 10 siblings, 0 replies; 16+ messages in thread From: joseph at codesourcery dot com @ 2006-03-01 23:01 UTC (permalink / raw) To: gcc-bugs ------- Comment #13 from joseph at codesourcery dot com 2006-03-01 23:01 ------- Subject: Re: should not warning with dead code A workaround is to use ? : and statement expressions instead of "if". This way, the front-end setting of skip_evaluation disables these warnings. (skip_evaluation can't be set for if (0) because you can jump into if (0), whereas jumps into statement expressions are not permitted. Thus in general you need to parse the whole function body to tell if the if (0) is dead.) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-955@http.gcc.gnu.org/bugzilla/> 2006-03-01 19:02 ` [Bug middle-end/4210] should not warning with dead code pinskia at gcc dot gnu dot org 2006-03-01 23:01 ` joseph at codesourcery dot com @ 2006-03-01 23:05 ` bangerth at dealii dot org 2006-03-01 23:22 ` joseph at codesourcery dot com ` (7 subsequent siblings) 10 siblings, 0 replies; 16+ messages in thread From: bangerth at dealii dot org @ 2006-03-01 23:05 UTC (permalink / raw) To: gcc-bugs ------- Comment #14 from bangerth at dealii dot org 2006-03-01 23:05 ------- But that's a) clearly a kludge, b) may not help in the future if our optimizers become more elaborate c) doesn't work with code where the code guarded by the if(0) is more than a single statement. It would definitely be better to have this fixed in the right place... W. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-955@http.gcc.gnu.org/bugzilla/> ` (2 preceding siblings ...) 2006-03-01 23:05 ` bangerth at dealii dot org @ 2006-03-01 23:22 ` joseph at codesourcery dot com 2006-03-01 23:25 ` bangerth at dealii dot org ` (6 subsequent siblings) 10 siblings, 0 replies; 16+ messages in thread From: joseph at codesourcery dot com @ 2006-03-01 23:22 UTC (permalink / raw) To: gcc-bugs ------- Comment #15 from joseph at codesourcery dot com 2006-03-01 23:22 ------- Subject: Re: should not warning with dead code On Wed, 1 Mar 2006, bangerth at dealii dot org wrote: > c) doesn't work with code where the code guarded by the if(0) is more > than a single statement. It does; I've used it to eliminate all these warnings in glibc's soft-fp code. Use statement expressions, i.e. surround the whole if body with ({ }). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-955@http.gcc.gnu.org/bugzilla/> ` (3 preceding siblings ...) 2006-03-01 23:22 ` joseph at codesourcery dot com @ 2006-03-01 23:25 ` bangerth at dealii dot org 2006-03-02 9:22 ` mattias at virtutech dot se ` (5 subsequent siblings) 10 siblings, 0 replies; 16+ messages in thread From: bangerth at dealii dot org @ 2006-03-01 23:25 UTC (permalink / raw) To: gcc-bugs ------- Comment #16 from bangerth at dealii dot org 2006-03-01 23:25 ------- > It does; I've used it to eliminate all these warnings in glibc's soft-fp > code. Use statement expressions, i.e. surround the whole if body with ({ > }). Ugh. Do we really want to advocate serious code obfuscation to avoid warnings? W. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-955@http.gcc.gnu.org/bugzilla/> ` (4 preceding siblings ...) 2006-03-01 23:25 ` bangerth at dealii dot org @ 2006-03-02 9:22 ` mattias at virtutech dot se 2006-06-20 19:08 ` pinskia at gcc dot gnu dot org ` (4 subsequent siblings) 10 siblings, 0 replies; 16+ messages in thread From: mattias at virtutech dot se @ 2006-03-02 9:22 UTC (permalink / raw) To: gcc-bugs ------- Comment #17 from mattias at virtutech dot se 2006-03-02 09:22 ------- We have resorted to case-by-case workarounds, usually a cast which would have been an identity operation had the condition been true. That is, if (sizeof x == 8) return x << 32 | x; would have its second line mutated to return (unsigned long long)x << 32 | x; The cast is always a no-op unless it occurs in dead code. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-955@http.gcc.gnu.org/bugzilla/> ` (5 preceding siblings ...) 2006-03-02 9:22 ` mattias at virtutech dot se @ 2006-06-20 19:08 ` pinskia at gcc dot gnu dot org 2007-01-01 19:03 ` pinskia at gcc dot gnu dot org ` (3 subsequent siblings) 10 siblings, 0 replies; 16+ messages in thread From: pinskia at gcc dot gnu dot org @ 2006-06-20 19:08 UTC (permalink / raw) To: gcc-bugs ------- Comment #18 from pinskia at gcc dot gnu dot org 2006-06-20 19:05 ------- *** Bug 28106 has been marked as a duplicate of this bug. *** -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |eggert at gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-955@http.gcc.gnu.org/bugzilla/> ` (6 preceding siblings ...) 2006-06-20 19:08 ` pinskia at gcc dot gnu dot org @ 2007-01-01 19:03 ` pinskia at gcc dot gnu dot org 2009-05-12 14:50 ` pinskia at gcc dot gnu dot org ` (2 subsequent siblings) 10 siblings, 0 replies; 16+ messages in thread From: pinskia at gcc dot gnu dot org @ 2007-01-01 19:03 UTC (permalink / raw) To: gcc-bugs ------- Comment #19 from pinskia at gcc dot gnu dot org 2007-01-01 19:03 ------- *** Bug 30343 has been marked as a duplicate of this bug. *** -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |gjasny at web dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-955@http.gcc.gnu.org/bugzilla/> ` (7 preceding siblings ...) 2007-01-01 19:03 ` pinskia at gcc dot gnu dot org @ 2009-05-12 14:50 ` pinskia at gcc dot gnu dot org 2010-07-06 17:24 ` manu at gcc dot gnu dot org 2010-07-06 17:28 ` manu at gcc dot gnu dot org 10 siblings, 0 replies; 16+ messages in thread From: pinskia at gcc dot gnu dot org @ 2009-05-12 14:50 UTC (permalink / raw) To: gcc-bugs ------- Comment #20 from pinskia at gcc dot gnu dot org 2009-05-12 14:49 ------- *** Bug 40114 has been marked as a duplicate of this bug. *** -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |gowen at innovative- | |technology dot co dot uk http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-955@http.gcc.gnu.org/bugzilla/> ` (8 preceding siblings ...) 2009-05-12 14:50 ` pinskia at gcc dot gnu dot org @ 2010-07-06 17:24 ` manu at gcc dot gnu dot org 2010-07-06 17:28 ` manu at gcc dot gnu dot org 10 siblings, 0 replies; 16+ messages in thread From: manu at gcc dot gnu dot org @ 2010-07-06 17:24 UTC (permalink / raw) To: gcc-bugs ------- Comment #21 from manu at gcc dot gnu dot org 2010-07-06 17:24 ------- *** Bug 44842 has been marked as a duplicate of this bug. *** -- manu at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |vincent at vinc17 dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-955@http.gcc.gnu.org/bugzilla/> ` (9 preceding siblings ...) 2010-07-06 17:24 ` manu at gcc dot gnu dot org @ 2010-07-06 17:28 ` manu at gcc dot gnu dot org 10 siblings, 0 replies; 16+ messages in thread From: manu at gcc dot gnu dot org @ 2010-07-06 17:28 UTC (permalink / raw) To: gcc-bugs ------- Comment #22 from manu at gcc dot gnu dot org 2010-07-06 17:28 ------- The way Clang gets this right is to perform some very-fast bitmap common constant propagation in the FE. I personally think this would be helpful if implemented correctly, even if it slows down the FE a little. But do not wait for a fix soon because this is not trivial to fix and no one has both the desire and the free time to work on fixing this. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 ^ permalink raw reply [flat|nested] 16+ messages in thread
[parent not found: <bug-4210-4@http.gcc.gnu.org/bugzilla/>]
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-4@http.gcc.gnu.org/bugzilla/> @ 2014-03-13 2:10 ` pinskia at gcc dot gnu.org 2014-08-09 6:09 ` pinskia at gcc dot gnu.org ` (3 subsequent siblings) 4 siblings, 0 replies; 16+ messages in thread From: pinskia at gcc dot gnu.org @ 2014-03-13 2:10 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |xzfcpw+gcc at gmail dot com --- Comment #23 from Andrew Pinski <pinskia at gcc dot gnu.org> --- *** Bug 60513 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-4@http.gcc.gnu.org/bugzilla/> 2014-03-13 2:10 ` pinskia at gcc dot gnu.org @ 2014-08-09 6:09 ` pinskia at gcc dot gnu.org 2020-04-26 21:28 ` nisse at lysator dot liu.se ` (2 subsequent siblings) 4 siblings, 0 replies; 16+ messages in thread From: pinskia at gcc dot gnu.org @ 2014-08-09 6:09 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |brooks at gcc dot gnu.org --- Comment #24 from Andrew Pinski <pinskia at gcc dot gnu.org> --- *** Bug 62074 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-4@http.gcc.gnu.org/bugzilla/> 2014-03-13 2:10 ` pinskia at gcc dot gnu.org 2014-08-09 6:09 ` pinskia at gcc dot gnu.org @ 2020-04-26 21:28 ` nisse at lysator dot liu.se 2020-05-04 20:44 ` nisse at lysator dot liu.se 2020-05-05 2:17 ` vincent-gcc at vinc17 dot net 4 siblings, 0 replies; 16+ messages in thread From: nisse at lysator dot liu.se @ 2020-04-26 21:28 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 Niels Möller <nisse at lysator dot liu.se> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nisse at lysator dot liu.se --- Comment #31 from Niels Möller <nisse at lysator dot liu.se> --- *** Bug 94773 has been marked as a duplicate of this bug. *** ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-4@http.gcc.gnu.org/bugzilla/> ` (2 preceding siblings ...) 2020-04-26 21:28 ` nisse at lysator dot liu.se @ 2020-05-04 20:44 ` nisse at lysator dot liu.se 2020-05-05 2:17 ` vincent-gcc at vinc17 dot net 4 siblings, 0 replies; 16+ messages in thread From: nisse at lysator dot liu.se @ 2020-05-04 20:44 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 --- Comment #32 from Niels Möller <nisse at lysator dot liu.se> --- I've checked out the gcc sources, to see if I can understand how to move the warning around. The example input I'm looking at now is unsigned shift_dead (unsigned x) { if (0) return x >> 32; else return x >> 1; } unsigned shift_invalid (unsigned x) { return x >> 32; } where I'd like gcc -Wall to warn for the second function, but not from the first (currently, it warns for both). The warning is emitted from build_binary_op, in gcc/c/c-typeck.c, close to line 11880. Deleting it there silences the warning for *both* functions above. I have a few questions. Keep in mind that I only have a very vague understanding of the different phases in gcc, so any guidance is appreciated. 1. There's similar code in c_fully_fold_internal, in gcc/c/c-fold.c, close to line 400. But that code does *not* emit any warning for the example above, which surprised me a bit. Maybe that's only for the case that both operands to the shift operator are constants? 2. More importantly, if the warning is deleted from build_binary_op, we need to add a check for this case, and an appropriate warning, somewhere later in the compilation process. It has to be done after dead code is identified, i.e., in a phase processing only non-dead code. And preferably as early as possibly, when we're still working close to the parse-tree representation. Is there such a place? Some other functions traversing the tree are c_gimplify_expr (gcc/c-family/c-gimplify.c) and verify_tree (gcc/c-family/c-common.c), are any of those called after elimination of dead code? 3. Alternatively, if there's no place after dead code elimination where the parse tree is still easily available, a different alternative could be to leave the check for invalid shift counts in c-typeck.c, but instead of emitting a warning, construct a special tree object representing an expression with invalid/undefined behavior, and any meta data needed to emit a warning or error to describe it? Then emission of the warning could be postponed to later, say, close to the conversion to SSA form? 4. I also wonder what happens if, for some reason, a constant invalid shift count is passed through all the way to code generation? Most architectures would represent a constant shift count for a 32-bit value as 5-bit field in the opcode, and then the invalid shift counts aren't representable at all. Will gcc silently ignore higher bits, or is it an internal compiler error, or would it make sense to produce a friendly warning at this late stage of the compilation? ^ permalink raw reply [flat|nested] 16+ messages in thread
* [Bug middle-end/4210] should not warning with dead code [not found] <bug-4210-4@http.gcc.gnu.org/bugzilla/> ` (3 preceding siblings ...) 2020-05-04 20:44 ` nisse at lysator dot liu.se @ 2020-05-05 2:17 ` vincent-gcc at vinc17 dot net 4 siblings, 0 replies; 16+ messages in thread From: vincent-gcc at vinc17 dot net @ 2020-05-05 2:17 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210 --- Comment #33 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> --- (In reply to Niels Möller from comment #32) > 4. I also wonder what happens if, for some reason, a constant invalid shift > count is passed through all the way to code generation? Most architectures > would represent a constant shift count for a 32-bit value as 5-bit field in > the opcode, and then the invalid shift counts aren't representable at all. > Will gcc silently ignore higher bits, That's undefined behavior, so that GCC can do whatever it wants for the generated code. > or is it an internal compiler error, This would not be acceptable. ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2020-05-05 2:17 UTC | newest] Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <bug-4210-955@http.gcc.gnu.org/bugzilla/> 2006-03-01 19:02 ` [Bug middle-end/4210] should not warning with dead code pinskia at gcc dot gnu dot org 2006-03-01 23:01 ` joseph at codesourcery dot com 2006-03-01 23:05 ` bangerth at dealii dot org 2006-03-01 23:22 ` joseph at codesourcery dot com 2006-03-01 23:25 ` bangerth at dealii dot org 2006-03-02 9:22 ` mattias at virtutech dot se 2006-06-20 19:08 ` pinskia at gcc dot gnu dot org 2007-01-01 19:03 ` pinskia at gcc dot gnu dot org 2009-05-12 14:50 ` pinskia at gcc dot gnu dot org 2010-07-06 17:24 ` manu at gcc dot gnu dot org 2010-07-06 17:28 ` manu at gcc dot gnu dot org [not found] <bug-4210-4@http.gcc.gnu.org/bugzilla/> 2014-03-13 2:10 ` pinskia at gcc dot gnu.org 2014-08-09 6:09 ` pinskia at gcc dot gnu.org 2020-04-26 21:28 ` nisse at lysator dot liu.se 2020-05-04 20:44 ` nisse at lysator dot liu.se 2020-05-05 2:17 ` vincent-gcc at vinc17 dot net
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).