public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/94414] New: only `--` gives constexpr
@ 2020-03-30 21:58 dmusiienko at gmail dot com
  2020-03-31  7:43 ` [Bug c++/94414] " rguenth at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: dmusiienko at gmail dot com @ 2020-03-30 21:58 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94414
           Summary: only `--` gives constexpr
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dmusiienko at gmail dot com
  Target Milestone: ---

x86-64 gcc (trunk)
-std=c++20 -O3

`++` - is not constexpr
`--` - is constexpr

==========================================
#include <ranges>
#include <array>

namespace rv = std::views;

int main()
{
    constexpr std::array arr{5, 6, 7, 8};
    auto contfilt = arr | rv::filter([](auto x){return x>5;})
    | rv::transform([](auto x){return x*x;});
    return *(++contfilt.begin());
}

===========================================

main:
        movdqa  xmm0, XMMWORD PTR .LC0[rip]
        lea     rax, [rsp-16]
        movaps  XMMWORD PTR [rsp-24], xmm0
        jmp     .L3
.L6:
        add     rax, 4
        lea     rdx, [rsp-8]
        cmp     rax, rdx
        je      .L2
.L3:
        cmp     DWORD PTR [rax], 5
        jle     .L6
.L2:
        mov     eax, DWORD PTR [rax]
        imul    eax, eax
        ret
.LC0:
        .long   5
        .long   6
        .long   7
        .long   8
=========================================

Okay, but ...

========================================

#include <ranges>
#include <array>

namespace rv = std::views;

int main()
{
    constexpr std::array arr{5, 6, 7, 8};
    auto contfilt = arr | rv::filter([](auto x){return x>5;})
    | rv::transform([](auto x){return x*x;});
    return *(----contfilt.end());
}

========================================

main:
        mov     eax, 49
        ret

========================================

Okay, but.....

========================================

#include <ranges>
#include <array>

namespace rv = std::views;

int main()
{
    constexpr std::array arr{5, 6, 7, 8};
    auto contfilt = arr | rv::filter([](auto x){return x>5;})
    | rv::transform([](auto x){return x*x;});
    return *(++(------contfilt.end()));
}

========================================

main:
        mov     eax, 49
        ret

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

end of thread, other threads:[~2021-12-14  8:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30 21:58 [Bug c++/94414] New: only `--` gives constexpr dmusiienko at gmail dot com
2020-03-31  7:43 ` [Bug c++/94414] " rguenth at gcc dot gnu.org
2020-03-31  9:09 ` redi at gcc dot gnu.org
2020-03-31 15:02 ` ppalka at gcc dot gnu.org
2021-12-14  8:54 ` [Bug tree-optimization/94414] " pinskia 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).