[cfe-dev] A trivial test case requires guard variable but it need not

Richard Smith richard at metafoo.co.uk
Mon Feb 13 17:27:59 PST 2012

On Mon, Feb 13, 2012 at 3:09 PM, jahanian <fjahanian at apple.com> wrote:

> I am not sure which of the recent patches related to recent c++11
> initializer work caused this.
> In this trivial test case, clang now generates a guard variable. It need
> not. This breaks several
> of our projects which do not  need (must not have) guard variable.
> class IOService;
> struct IOSurfaceSendRight { void foo(); };
> typedef int (IOService::*IOMethod)();
> void a() {
>  static IOMethod x = (IOMethod)&IOSurfaceSendRight::foo;
> }

We lost this in a 'cleanup' change quite a while back, which removed the
clang::Expr -> llvm::Constant emission of member pointers, under the theory
that the clang::APValue -> llvm::Constant emission covered all use cases.
It appears that reinterpret_casts of pointers to members were covered by
the old code but not the new code :-(

It should hopefully be straightforward to extend the constant expression
evaluator to deal with such reinterpret_casts.

- Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120213/b4a5db59/attachment.html>

More information about the cfe-dev mailing list