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

consteval function not allowed in default argument to constexpr constructor #48230

Closed
andreasfertig opened this issue Jan 26, 2021 · 7 comments
Closed
Labels
bugzilla Issues migrated from bugzilla c++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party libstdc++ GNU libstdc++ C++ standard library

Comments

@andreasfertig
Copy link
Contributor

andreasfertig commented Jan 26, 2021

Bugzilla Link 48886
Version 11.0
OS All
CC @AaronBallman,@zygoloid

Extended Description

Hello,

the following valid code is currently rejected by Clang 11 and trunk (https://godbolt.org/z/645McM):

consteval int Fun() { return 0; }

struct Test {
  constexpr Test(int loc = Fun()) {}
};

Test t{};

The error is:

<source>:4:28: error: cannot take address of consteval function 'Fun' outside of an immediate invocation
  constexpr Test(int loc = Fun()) {}
                           ^
<source>:1:15: note: declared here
consteval int Fun() { return 0; }
              ^
1 error generated.
Compiler returned: 1

I had a brief communication with Richard Smith who confirmed that the code above is valid.

I assume this bug is similar to #47058

Best,

Andreas

@AaronBallman
Copy link
Collaborator

*** Bug llvm/llvm-bugzilla-archive#51483 has been marked as a duplicate of this bug. ***

@AaronBallman
Copy link
Collaborator

*** Bug #47058 has been marked as a duplicate of this bug. ***

@AaronBallman
Copy link
Collaborator

mentioned in issue llvm/llvm-bugzilla-archive#51483

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
@llvmbot llvmbot added the confirmed Verified by a second party label Jan 26, 2022
@Izaron
Copy link
Member

Izaron commented Feb 12, 2022

Thanks for the issue! I suggested a possible fix, which affects the ParmVarDecl's custom AST visitor - https://reviews.llvm.org/D119646

@EugeneZelenko EugeneZelenko added the clang:frontend Language frontend issues, e.g. anything involving "Sema" label Feb 12, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 12, 2022

@llvm/issue-subscribers-clang-frontend

tchaikov added a commit to ceph/seastar that referenced this issue May 13, 2022
in a recent clang change, __builtin_source_location was added.
see https://reviews.llvm.org/rGd61487490022 . but a bug in clang
frontend pratically prevents us from using it. see
llvm/llvm-project#48230. so before this
issue is fixed, we have to prevent clang from using the builtin
source location implementation.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
tchaikov added a commit to tchaikov/seastar that referenced this issue May 16, 2022
in a recent clang change, __builtin_source_location was added.
see https://reviews.llvm.org/rGd61487490022 . but a bug in clang
frontend pratically prevents us from using it. see
llvm/llvm-project#48230. so before this
issue is fixed, we have to prevent clang from using the builtin
source location implementation.

in this change, a new library is added for introducing the macro
of "SEASTAR_BROKEN_SOURCE_LOCATION", if it is defined we'd have to
use the homebrew implementation of source_location even the header
file of <source_location> or <experimental/source_location> can be
found by the C++ compiler.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
tchaikov added a commit to tchaikov/seastar that referenced this issue May 16, 2022
in a recent clang change, __builtin_source_location was added.
see https://reviews.llvm.org/rGd61487490022 . but a bug in clang
frontend pratically prevents us from using it. see
llvm/llvm-project#48230. so before this
issue is fixed, we have to prevent clang from using the builtin
source location implementation.

in this change, a new library is added for introducing the macro
of "SEASTAR_BROKEN_SOURCE_LOCATION", if it is defined we'd have to
use the homebrew implementation of source_location even the header
file of <source_location> or <experimental/source_location> can be
found by the C++ compiler.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
tchaikov added a commit to tchaikov/seastar that referenced this issue May 16, 2022
in a recent clang change, __builtin_source_location was added.
see https://reviews.llvm.org/rGd61487490022 . but a bug in clang
frontend pratically prevents us from using it. see
llvm/llvm-project#48230. so before this
issue is fixed, we have to prevent clang from using the builtin
source location implementation.

in this change, a new library is added for introducing the macro
of "SEASTAR_BROKEN_SOURCE_LOCATION", if it is defined we'd have to
use the homebrew implementation of source_location even the header
file of <source_location> or <experimental/source_location> can be
found by the C++ compiler.

please note, -std=c++20 is not added to CMAKE_REQUIRED_FLAGS when
performing the test, because we want to ensure that we are using
the same CXX_FLAGS as the ones when compiling std-compat.hh.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
avikivity pushed a commit to avikivity/seastar that referenced this issue May 16, 2022
in a recent clang change, __builtin_source_location was added.
see https://reviews.llvm.org/rGd61487490022 . but a bug in clang
frontend pratically prevents us from using it. see
llvm/llvm-project#48230. so before this
issue is fixed, we have to prevent clang from using the builtin
source location implementation.

in this change, a new library is added for introducing the macro
of "SEASTAR_BROKEN_SOURCE_LOCATION", if it is defined we'd have to
use the homebrew implementation of source_location even the header
file of <source_location> or <experimental/source_location> can be
found by the C++ compiler.

please note, -std=c++20 is not added to CMAKE_REQUIRED_FLAGS when
performing the test, because we want to ensure that we are using
the same CXX_FLAGS as the ones when compiling std-compat.hh.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
Message-Id: <20220516151733.411546-1-tchaikov@gmail.com>
tchaikov added a commit to tchaikov/seastar that referenced this issue May 17, 2022
in a recent clang change, __builtin_source_location was added.
see https://reviews.llvm.org/rGd61487490022 . but a bug in clang
frontend pratically prevents us from using it. see
llvm/llvm-project#48230. so before this
issue is fixed, we have to prevent clang from using the builtin
source location implementation.

in this change, a new library is added for introducing the macro
of "SEASTAR_BROKEN_SOURCE_LOCATION", if it is defined we'd have to
use the homebrew implementation of source_location even the header
file of <source_location> or <experimental/source_location> can be
found by the C++ compiler.

please note, -std=c++20 is not added to CMAKE_REQUIRED_FLAGS when
performing the test, because we want to ensure that we are using
the same CXX_FLAGS as the ones when compiling std-compat.hh.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
tchaikov added a commit to tchaikov/seastar that referenced this issue May 17, 2022
in a recent clang change, __builtin_source_location was added.
see https://reviews.llvm.org/rGd61487490022 . but a bug in clang
frontend pratically prevents us from using it. see
llvm/llvm-project#48230. so before this
issue is fixed, we have to prevent clang from using the builtin
source location implementation.

in this change, a new library is added for introducing the macro
of "SEASTAR_BROKEN_SOURCE_LOCATION", if it is defined we'd have to
use the homebrew implementation of source_location even the header
file of <source_location> or <experimental/source_location> can be
found by the C++ compiler.

please note, -std=c++20 is not added to CMAKE_REQUIRED_FLAGS when
performing the test, because we want to ensure that we are using
the same CXX_FLAGS as the ones when compiling std-compat.hh.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
tchaikov added a commit to tchaikov/seastar that referenced this issue May 18, 2022
in a recent clang change, __builtin_source_location was added.
see https://reviews.llvm.org/rGd61487490022 . but a bug in clang
frontend pratically prevents us from using it. see
llvm/llvm-project#48230. so before this
issue is fixed, we have to prevent clang from using the builtin
source location implementation.

in this change, a new library is added for introducing the macro
of "SEASTAR_BROKEN_SOURCE_LOCATION", if it is defined we'd have to
use the homebrew implementation of source_location even the header
file of <source_location> or <experimental/source_location> can be
found by the C++ compiler.

please note, -std=c++20 is not added to CMAKE_REQUIRED_FLAGS when
performing the test, because we want to ensure that we are using
the same CXX_FLAGS as the ones when compiling std-compat.hh.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
tchaikov added a commit to tchaikov/seastar that referenced this issue May 19, 2022
in a recent clang change, __builtin_source_location was added.
see https://reviews.llvm.org/rGd61487490022 . but a bug in clang
frontend pratically prevents us from using it. see
llvm/llvm-project#48230. so before this
issue is fixed, we have to prevent clang from using the builtin
source location implementation.

in this change, a new library is added for introducing the macro
of "SEASTAR_BROKEN_SOURCE_LOCATION", if it is defined we'd have to
use the homebrew implementation of source_location even the header
file of <source_location> or <experimental/source_location> can be
found by the C++ compiler.

please note, -std=c++20 is not added to CMAKE_REQUIRED_FLAGS when
performing the test, because we want to ensure that we are using
the same CXX_FLAGS as the ones when compiling std-compat.hh.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
tchaikov added a commit to tchaikov/seastar that referenced this issue May 19, 2022
in a recent clang change, __builtin_source_location was added.
see https://reviews.llvm.org/rGd61487490022 . but a bug in clang
frontend pratically prevents us from using it. see
llvm/llvm-project#48230. so before this
issue is fixed, we have to prevent clang from using the builtin
source location implementation.

in this change, a new library is added for introducing the macro
of "SEASTAR_BROKEN_SOURCE_LOCATION", if it is defined we'd have to
use the homebrew implementation of source_location even the header
file of <source_location> or <experimental/source_location> can be
found by the C++ compiler.

please note, -std=c++20 is not added to CMAKE_REQUIRED_FLAGS when
performing the test, because we want to ensure that we are using
the same CXX_FLAGS as the ones when compiling std-compat.hh.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
avikivity pushed a commit to scylladb/seastar that referenced this issue May 19, 2022
in a recent clang change, __builtin_source_location was added.
see https://reviews.llvm.org/rGd61487490022 . but a bug in clang
frontend pratically prevents us from using it. see
llvm/llvm-project#48230. so before this
issue is fixed, we have to prevent clang from using the builtin
source location implementation.

in this change, a new library is added for introducing the macro
of "SEASTAR_BROKEN_SOURCE_LOCATION", if it is defined we'd have to
use the homebrew implementation of source_location even the header
file of <source_location> or <experimental/source_location> can be
found by the C++ compiler.

please note, -std=c++20 is not added to CMAKE_REQUIRED_FLAGS when
performing the test, because we want to ensure that we are using
the same CXX_FLAGS as the ones when compiling std-compat.hh.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
Message-Id: <20220519134839.1818862-2-tchaikov@gmail.com>
avikivity pushed a commit to scylladb/seastar that referenced this issue May 19, 2022
in a recent clang change, __builtin_source_location was added.
see https://reviews.llvm.org/rGd61487490022 . but a bug in clang
frontend pratically prevents us from using it. see
llvm/llvm-project#48230. so before this
issue is fixed, we have to prevent clang from using the builtin
source location implementation.

in this change, a new library is added for introducing the macro
of "SEASTAR_BROKEN_SOURCE_LOCATION", if it is defined we'd have to
use the homebrew implementation of source_location even the header
file of <source_location> or <experimental/source_location> can be
found by the C++ compiler.

please note, -std=c++20 is not added to CMAKE_REQUIRED_FLAGS when
performing the test, because we want to ensure that we are using
the same CXX_FLAGS as the ones when compiling std-compat.hh.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
Message-Id: <20220519134839.1818862-2-tchaikov@gmail.com>
avikivity pushed a commit to scylladb/seastar that referenced this issue May 19, 2022
in a recent clang change, __builtin_source_location was added.
see https://reviews.llvm.org/rGd61487490022 . but a bug in clang
frontend pratically prevents us from using it. see
llvm/llvm-project#48230. so before this
issue is fixed, we have to prevent clang from using the builtin
source location implementation.

in this change, a new library is added for introducing the macro
of "SEASTAR_BROKEN_SOURCE_LOCATION", if it is defined we'd have to
use the homebrew implementation of source_location even the header
file of <source_location> or <experimental/source_location> can be
found by the C++ compiler.

please note, -std=c++20 is not added to CMAKE_REQUIRED_FLAGS when
performing the test, because we want to ensure that we are using
the same CXX_FLAGS as the ones when compiling std-compat.hh.

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
Message-Id: <20220519134839.1818862-2-tchaikov@gmail.com>
@jyknight jyknight added the libstdc++ GNU libstdc++ C++ standard library label May 30, 2022
@jyknight
Copy link
Member

Note that this bug is causing std::source_location in libstdc++ to be broken -- and also effectively blocking source_location for libc++, https://reviews.llvm.org/D120634 (not much point in committing it if nobody can use it).

@ChuanqiXu9 ChuanqiXu9 assigned ChuanqiXu9 and unassigned ChuanqiXu9 May 31, 2022
@tstellar
Copy link
Collaborator

tstellar commented Jun 1, 2022

@jwakely

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++20 clang:frontend Language frontend issues, e.g. anything involving "Sema" confirmed Verified by a second party libstdc++ GNU libstdc++ C++ standard library
Projects
None yet
Development

No branches or pull requests

8 participants