[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #18 from manu at gcc dot gnu dot org 2008-08-23 15:59 --- (In reply to comment #0) Compiling the following with -Wunreachable-code -D_GLIBCXX_DEBUG -- #include vector int main() { std::vectorint::iterator a; } -- produces the warning : I cannot reproduce this in GCC 4.4. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #19 from manu at gcc dot gnu dot org 2008-08-23 16:01 --- (In reply to comment #4) Here is a minimal code example: #include new int* get_ptr(void* ptr) { return new(ptr) int(); } I can reproduce this, though. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #20 from manu at gcc dot gnu dot org 2008-08-23 16:13 --- For testcase in comment #4 I get 2 warnings now: home/manuel/test2/src/gcc/testsuite/g++.dg/warn/pr31246-2.C: In function int* get_ptr(void*): /home/manuel/test2/src/gcc/testsuite/g++.dg/warn/pr31246-2.C:8: warning: will never be executed /home/manuel/test2/src/libstdc++-v3/libsupc++/new: In function void* operator new(size_t, void*): /home/manuel/test2/src/libstdc++-v3/libsupc++/new:105: warning: will never be executed libsupc++/new does not contain #pragma GCC system_headers, so even using warning_at doesn't suppress the warning. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #21 from manu at gcc dot gnu dot org 2008-08-23 16:21 --- If gimple stmts do not have the equivalent of DECL_ARTIFICIAL, then the C++ front-end should use gimple_set_no_warning(stmt) when generating such constructs. So, anyone knows where this comes from? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #22 from manu at gcc dot gnu dot org 2008-08-23 17:24 --- In addition, __cxa_call_unexpected should probably have both TREE_NO_WARNING and DECL_ARTIFICIAL set but this is orthogonal because at the point of the warning we should not be testing that. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #23 from paolo dot carlini at oracle dot com 2008-08-23 18:43 --- To be clear, there are no #pragma GCC system_header at all in the entire libsupc++ directory. I hope we don't have to begin... -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #9 from manu at gcc dot gnu dot org 2007-03-19 13:56 --- (In reply to comment #8) I agree with you Paolo. The front-end should make sure that its artefacts don't adversily affect diagnostics we emit. I agree to some extend. The reason why the try/catch is there is because of what the C++ standard says should happen and not really an artafact of what the GCC is doing really. When I first say this bug I was going to say this should not warned about, but when I looked into it a little more, I was thinking the warning is correct except for the fact, there is no way of working around the issue. I think we need to decide what -Wunreachable-code actually means, does it mean if there is a way to fix the code, then warn about unreachable code or does it mean to warn about code which is even hard to work around like in templates and constructors? And I think that we should not warn about generated code. No matter if it is generated by optimisers or front-ends. If it is not user code, then there should be no warning. In that sense, this is similar to PR31227. -- manu at gcc dot gnu dot org changed: What|Removed |Added CC||manu at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #10 from gdr at cs dot tamu dot edu 2007-03-19 15:19 --- Subject: Re: Strange -Wunreachable-code warning with _GLIBCXX_DEBUG manu at gcc dot gnu dot org [EMAIL PROTECTED] writes: | And I think that we should not warn about generated code. No matter if it is | generated by optimisers or front-ends. If it is not user code, then there | should be no warning. I fully agree. -- Gaby -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #11 from pinskia at gcc dot gnu dot org 2007-03-19 22:31 --- (In reply to comment #10) I fully agree. I am not agreeing fully, This warning is only because we can prove something is pure/const/cannot throw and that only comes because of simple optimization. What about this case: int f(int a) { return a;} int g(int b) { try { return f(b); }catch (...) { return 0; } } Should we warn about the catch being unreachable? This is the same issue as -Wuninitialized warning in that we warn about a lot of cases where we should not. I think this is why this option is not turned on via either -W or -Wall, it is hard sometimes to work around. Take even more extrem example where templates come into play: int f(int a) { return a;} int f(float a); template typename a int g(a b) { try { return f(a); }catch (...) { return 0; } } int d = gint(10); Should we warn that the catch case is unreachable, I think so as it is obvious but how do we avoid it, well you can specialize the template but that could get messy. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
Re: [Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
pinskia at gcc dot gnu dot org [EMAIL PROTECTED] writes: | (In reply to comment #10) | | I fully agree. | | I am not agreeing fully, Well, you've got a problem. [...] | What about this case: There is a distinction betwen user code and compiler-generated codes. Warning about compiler-generated codes is pointless. -- Gaby
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #12 from gdr at cs dot tamu dot edu 2007-03-19 22:45 --- Subject: Re: Strange -Wunreachable-code warning with _GLIBCXX_DEBUG pinskia at gcc dot gnu dot org [EMAIL PROTECTED] writes: | (In reply to comment #10) | | I fully agree. | | I am not agreeing fully, Well, you've got a problem. [...] | What about this case: There is a distinction betwen user code and compiler-generated codes. Warning about compiler-generated codes is pointless. -- Gaby -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #13 from manu at gcc dot gnu dot org 2007-03-19 23:13 --- Andrew, as you say, -Wunreachable-code is not enabled by -Wall. The user has to give it explicitly. And in your testcases the code is not reachable. So in that case, it could be argued whether the warning is warranted or not. So, yes, you got a point. But... that is not what this PR is about. This PR is that the user cannot see the code we are warning about. Even if it were code with an easy workaround unlike your testcases, that doesn't matter at all, we should not emit the warning. -- manu at gcc dot gnu dot org changed: What|Removed |Added Status|UNCONFIRMED |NEW Ever Confirmed|0 |1 Last reconfirmed|-00-00 00:00:00 |2007-03-19 23:13:32 date|| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #14 from pinskia at gcc dot gnu dot org 2007-03-19 23:18 --- But the user can see the code, it is what is produced by what the C++ standard says is produced, now you could say the user has no control over fixing it, it is also true with the template case. Both cases are hard to fix without much thought. There is also something like: static inline int f(int a) { if (a) return g(); return 0; } int h(void) { return f(0); } With -Wunreachable-code -O1, we warn that we cannot reach the line containing return g(); Now should we, it is the same case, how can an user fix that code if the static inline function comes in from a header, they cannot. -Wunreachable-code warning is useless except if you want to see if you do coverage. -- pinskia at gcc dot gnu dot org changed: What|Removed |Added Status|NEW |RESOLVED Resolution||WONTFIX http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #15 from manu at gcc dot gnu dot org 2007-03-19 23:35 --- Andrew, you have Paolo and Gabriel expressing that the warning should not be emitted because the code is generated. Then you close as wontfix. Sometimes I don't understand you at all. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #16 from gdr at cs dot tamu dot edu 2007-03-19 23:40 --- Subject: Re: Strange -Wunreachable-code warning with _GLIBCXX_DEBUG pinskia at gcc dot gnu dot org [EMAIL PROTECTED] writes: | But the user can see the code, Andrew -- When you don't understand an issue, please refrain from offering your help to close it. -- Gaby -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #17 from pcarlini at suse dot de 2007-03-19 23:43 --- WONTFIX is simply ridicolous. -- pcarlini at suse dot de changed: What|Removed |Added Status|RESOLVED|REOPENED Resolution|WONTFIX | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #6 from pcarlini at suse dot de 2007-03-17 20:48 --- And I'm recategorizing as C++: either (as I strongly believe) a very general diagnostic issue, or maybe a duplicate of C++/30500: certainly there is nothing we can do on the library side to fix the implementation of placement new itself (per Chris' comment #4. By the way, in that specific case I think we are missing the pragma from the header, because there are no templates involved and should work. But that's not the point). -- pcarlini at suse dot de changed: What|Removed |Added Component|libstdc++ |c++ http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #7 from gdr at cs dot tamu dot edu 2007-03-17 23:35 --- Subject: Re: Strange -Wunreachable-code warning with _GLIBCXX_DEBUG pcarlini at suse dot de [EMAIL PROTECTED] writes: | Note, however, that, as far as I can see, such try/catch are *not* in the | library code proper, but *all* synthesized by the C++ front-end. Is it so weird | to imagine for the C++ front-end to automatically suppress warning in such | case? I think this is a very general issue, which goes even beyond the already | general issue about pragma system headers: if the user writes such code and | sees such kind of warnings becomes *completely* confused. Gaby, do you have an | opinion? I agree with you Paolo. The front-end should make sure that its artefacts don't adversily affect diagnostics we emit. -- Gaby -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246
[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG
--- Comment #8 from pinskia at gcc dot gnu dot org 2007-03-18 05:38 --- I agree with you Paolo. The front-end should make sure that its artefacts don't adversily affect diagnostics we emit. I agree to some extend. The reason why the try/catch is there is because of what the C++ standard says should happen and not really an artafact of what the GCC is doing really. When I first say this bug I was going to say this should not warned about, but when I looked into it a little more, I was thinking the warning is correct except for the fact, there is no way of working around the issue. I think we need to decide what -Wunreachable-code actually means, does it mean if there is a way to fix the code, then warn about unreachable code or does it mean to warn about code which is even hard to work around like in templates and constructors? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246