[cfe-users] Is there a way to make clang warn on this code?

Quentin Colombet qcolombet at apple.com
Fri Mar 14 09:20:16 PDT 2014


Hi,

I recently found a non-deterministic behavior in my application that was due to a missing field initialization.
Here is a snippet of the actual problem:

struct foo {
  foo() {}; // <— bar is not initialized here.
  int getBar() const {
    return bar; // <— this returns an uninitialized value.
  }
private:
  int bar;
};

I’ve compiled the attached cpp file that contains this snippet with -Wall -Wextra -Wuninitialized, but no warning is issued (trunk 203678).
Is there an option to make clang warn about that?

If not, should I file a PR?

Thanks,
-Quentin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20140314/8cd60d2b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bar.cpp
Type: application/octet-stream
Size: 295 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20140314/8cd60d2b/attachment.obj>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20140314/8cd60d2b/attachment-0001.html>


More information about the cfe-users mailing list