[Bug c++/44673] static const variable works in if/else, fails at linking in ternary
manu at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Sat Jun 26 10:53:00 GMT 2010
------- Comment #14 from manu at gcc dot gnu dot org 2010-06-26 10:53 -------
> (In reply to comment #12)
> > So is g++ accepting invalid code?
>
> Yes, but it's a violation of the ODR, no diagnostic is required (it's not
> possible to tell until link time that there's no definition.)
>
> There are DOZENS of duplicates of this bug, they are all invalid.
However, it links in the if-else case. I understand that ?: may be used as a
lvalue, but in this case, it is not and the value may be inlined in the same
way as in if-else (I guess that is what Andrew's patch did). If the standard is
clear that this should not work, then so be it.
Let's close this as INVALID, because I don't know how we could improve the
diagnostics here to help users. I wish we could but I cannot see how it can be
done. I guess that would require an integrated super-smart linker, I wonder if
the LLVM project is going to suggest that next?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44673
More information about the Gcc-bugs
mailing list