Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

constexpr if condition is not a constant expression and std::is_same #36933

Closed
minib00m mannequin opened this issue May 25, 2018 · 2 comments
Closed

constexpr if condition is not a constant expression and std::is_same #36933

minib00m mannequin opened this issue May 25, 2018 · 2 comments
Labels
bugzilla Issues migrated from bugzilla c++17

Comments

@minib00m
Copy link
Mannequin

minib00m mannequin commented May 25, 2018

Bugzilla Link 37585
Resolution FIXED
Resolved on Jul 03, 2018 15:16
Version 6.0
OS Linux

Extended Description

I've found very simple case where clang gives wrong diagnosis.

Let's consider smallest possible program:

#include <type_traits>

int main() {
    if constexpr (std::is_same_v<int, int>) {}
    else if constexpr (std::is_same_v<double, int>) {}
}

clang outputs:

error: constexpr if condition is not a constant expression

    else if constexpr (std::is_same_v<double, int>) {}

Cause of this is statement:
if constexpr (std::is_same_v<int, int>)
any further if constexpr statement is not considered as constant expression.

@llvmbot
Copy link
Collaborator

llvmbot commented Jun 19, 2018

I put a patch up here: https://reviews.llvm.org/D48322

@llvmbot
Copy link
Collaborator

llvmbot commented Jul 3, 2018

The patch landed as r336233. Thanks for reporting this!

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++17
Projects
None yet
Development

No branches or pull requests

1 participant