This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/21951] [4.0 only] std::vector.reserve() unusable with -Werror -Wall -O -fno-exceptions
- From: "veksler at il dot ibm dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jun 2005 14:43:42 -0000
- Subject: [Bug libstdc++/21951] [4.0 only] std::vector.reserve() unusable with -Werror -Wall -O -fno-exceptions
- References: <20050607175818.21951.dank@kegel.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From veksler at il dot ibm dot com 2005-06-08 14:43 -------
(In reply to comment #7)
> It sure as hell is for those shops that require -Werror.
>
> But ok, I'll be happy if it's fixed for 4.0.2.
I think that your argument (as phrased) does not hold.
Maybe you meant "It sure as hell is for those shops that require -Werror,
in this particular instance".
(Pardon my language, I just quoted the original ;-)
Consider:
1. 1: int main()
2: {
3: int a;
4: never_return(); // the halting problem
5: return a; // Uninitialized variable?
6: }
This is perfectly valid code and well defined, yet -Wall -Werror
will reject it. No compiler will ever be able to determine if
line 5 is ever reached.
2. 1: int main()
2: {
3: int a;
4: if(foo())
5: a= bar();
6: if(foo())
7: return a; // Uninitialized variable?
8: return 0;
9: }
Again, no compiler will be able to prove that a nontrivial foo() does
not change over time (unless declared const/pure/whatever).
And as a result, -Wall -Werror will reject valid code.
In both examples, the user has a simple work-around, initialize 'a'.
Adding initialization will make the code more stable, as foo() is
no longer constrained to be const/pure (forgive me for not remembering if
it is called pure or const).
In contrast (as mentioned in comment #4), this PR and PR 21183 do not
give the user the tools to shut this specific diagnostic instance up.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21951