[cfe-dev] Refs are assumed not-null. How to disable?
Nick Lewycky
nlewycky at google.com
Fri May 30 11:23:53 PDT 2014
On 30 May 2014 11:06, David Blaikie <dblaikie at gmail.com> wrote:
> On Fri, May 30, 2014 at 10:28 AM, Óscar Fuentes <ofv at wanadoo.es> wrote:
> > With optmizations on, the `return' on this code:
> >
> > bool foo(int &k) {
> > return &k != nullptr;
> > }
> >
> > is reduced to `return true;'.
> >
> > Is there an option for disabling this optimization?
>
> Nope, this was committed in
> http://llvm.org/viewvc/llvm-project?rev=209723&view=rev and doesn't
> look like it has any flag control.
>
> This code has Undefined Behavior (by binding a dereferenced null
> pointer to a reference).
>
There isn't a warning for this. There should be a tautological comparison
warning here.
Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140530/79d421f1/attachment.html>
More information about the cfe-dev
mailing list