[cfe-dev] -Wglobal-constructors warns on constexpr default constructor evaluated at compile-time?

Gabriel Charette via cfe-dev cfe-dev at lists.llvm.org
Tue Jan 16 04:14:43 PST 2018


Aaaaah! I had definitely missed that this was about the *de*destructor..!

I would indeed expect, like Primiano, that -Wglobal-constructors would only
warn about *con*structors (one can decide to mitigate global *de*structors
another way, e.g. by invoking _exit() before end of main()).

On Tue, Jan 16, 2018 at 1:03 PM Malcolm Parsons <malcolm.parsons at gmail.com>
wrote:

> On 16 January 2018 at 10:10, Gabriel Charette via cfe-dev
> <cfe-dev at lists.llvm.org> wrote:
>
> > it seems that -Wglobal-constructors throws a warning on a global using a
> > constexpr default constructor on classes that don't strictly have POD
> > members only. Given constexpr + no params implies all members are either
> POD
> > or constexpr default constructible themselves, shouldn't Clang be able to
> > avoid the global constructor in all cases?
>
> The warning is about the *de*structor:
>
> > Foo f;  --> error: declaration requires a global destructor
> > [-Werror,-Wglobal-constructors]
>
> --
> Malcolm Parsons
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180116/c6341202/attachment.html>


More information about the cfe-dev mailing list