This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/25845] want optional warning for non-constant declarations that could be constant
- From: "sigra at home dot se" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Jan 2006 16:07:42 -0000
- Subject: [Bug c++/25845] want optional warning for non-constant declarations that could be constant
- References: <bug-25845-315@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from sigra at home dot se 2006-01-18 16:07 -------
Example 1:
{
int i = f();
do_something(i + 1, 7, 'h');
do_something_else(i % 3, 'e');
}
If i could be declared "const int", the compiler should warn.
Example 2:
float dra(float m, Panel & p) {
p.do_me(5);
return p.set_moad(m);
}
If m could be declared "const float", the compiler should warn.
Example 3:
{
char t = 2;
if (hej.is_double()) t *= 7;
std::cout << static_cast<unsigned short>(t) << std::endl;
}
If "static_cast<const unsigned short>" would work, the compiler should warn.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25845