public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/103443] New: consteval function rejected as constant expression
@ 2021-11-26 14:56 vincent.hamp at higaski dot at
  2021-11-26 16:32 ` [Bug c++/103443] " jakub at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: vincent.hamp at higaski dot at @ 2021-11-26 14:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103443

            Bug ID: 103443
           Summary: consteval function rejected as constant expression
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vincent.hamp at higaski dot at
  Target Milestone: ---

Not really sure whether that's a frontend or a libstdc++ bug, but GCC 11.1.0
(and according to godbolt trunk as well) does not accept the following snippet.


#include <cstdint>
#include <cstdio>
#include <utility>

// #define QUALIFIER constexpr // compiles
#define QUALIFIER consteval    // does not compile

template <size_t... Is>
QUALIFIER uint32_t index_sequence2mask(std::index_sequence<Is...>) {
    if constexpr (sizeof...(Is) == 0u)
        return 0u;
    else
        return ((1u << Is) | ...);
}

template <uint32_t Mask = index_sequence2mask(std::make_index_sequence<1u>{})>
void use_mask() {
    printf("%s\n", __PRETTY_FUNCTION__);
}

int main() { use_mask(); }


The code is rejected with the following error:
"expression 'std::make_index_sequence<1>{}' is not a constant expression"

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-03-04 15:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-26 14:56 [Bug c++/103443] New: consteval function rejected as constant expression vincent.hamp at higaski dot at
2021-11-26 16:32 ` [Bug c++/103443] " jakub at gcc dot gnu.org
2022-03-04 15:17 ` cvs-commit at gcc dot gnu.org
2022-03-04 15:29 ` ppalka at gcc dot gnu.org
2022-03-04 15:29 ` ppalka at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).