This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/64524] gcc can't detect same expression in both parts of ternary operator
- From: "maltsevm at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 07 Jan 2015 19:45:51 +0000
- Subject: [Bug c++/64524] gcc can't detect same expression in both parts of ternary operator
- Auto-submitted: auto-generated
- References: <bug-64524-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64524
Mikhail Maltsev <maltsevm at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |maltsevm at gmail dot com
--- Comment #4 from Mikhail Maltsev <maltsevm at gmail dot com> ---
> int k = cond ? sizeof (x) : sizeof (y);
By the way, this is a good example of probable "false positives". Consider:
constexpr std::size_t max_size = (sizeof(T1) > sizeof(T2)) ? sizeof(T1) :
sizeof(T2);
This is an example of "legal" code, it could be used for allocating a buffer
which could hold either object of type T1 or type T2. These sizes may be
platform-dependent (or they may depend on template parameters), so this code
makes sence, but it will produce a warning when sizes are equal.
So, probably this warning only makes sence, if ASTs' would be compared, not the
values.