Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.
This repository was archived by the owner on Aug 11, 2023. It is now read-only.

constexpr problems with MSVC #95

@ProGTX

Description

@ProGTX

I've noticed that the Gaussian blur sample fails to compile with Visual Studio 2015 using ComputeCpp 0.6:

gaussian-blur.cpp(159): error C2131: expression did not evaluate to a constant
gaussian-blur.cpp(159): note: failure was caused by non-constant arguments or reference to a non-constant symbol

This is referring to this line of the GaussianKernel kernel lambda:

constexpr auto offset = 3 * stddev;

Even though stddev is a constexpr variable that was declared outside the kernel lambda, it's not considered constexpr inside the kernel lambda.

I believe this is a Visual Studio bug that's not even been fixed in MSVC 2017 (https://godbolt.org/g/t7n1uW).

Interestingly, it seems that making the constexpr variable static constexpr solves this problem, so maybe this should be the default way of using constexpr variables inside kernels.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions