public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/99309] New: Segmentation fault with __builtin_constant_p usage at -O2
@ 2021-02-28 10:33 gcc at mailinator dot com
  2021-03-01  9:31 ` [Bug c++/99309] [10/11 Regression] " rguenth at gcc dot gnu.org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: gcc at mailinator dot com @ 2021-02-28 10:33 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99309
           Summary: Segmentation fault with __builtin_constant_p usage at
                    -O2
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gcc at mailinator dot com
  Target Milestone: ---

Compile:

g++ -O2 a.cpp
./a.out


Current output:

1 610334368
Segmentation fault (core dumped)

Code:

#include<iostream>

struct T {
        int val;
        explicit constexpr operator int() const { return val; }
        constexpr T(int64_t v):val(v){}
        void operator*=(T m) {
                //std::cerr<<"start\n";
                if(__builtin_constant_p(m.val)){
                        std::cerr<<"normal\n";
                        return;
                }else if(__builtin_constant_p(val)){
                        std::cerr<<"recursive\n";
                        return;
                }else{
                        std::cerr<<"return\n";
                        return;
                }
        }
};


int main(){
        T constexpr step=610334368;
        T value=1;
        for(int _=0; _<100; ++_){
                std::cerr<<(int)value<<' '<<(int)step<<'\n';
                value*=step;
                std::cerr<<(int)value<<' '<<(int)step<<'\n';
        }
}

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

end of thread, other threads:[~2023-08-17  0:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-28 10:33 [Bug c++/99309] New: Segmentation fault with __builtin_constant_p usage at -O2 gcc at mailinator dot com
2021-03-01  9:31 ` [Bug c++/99309] [10/11 Regression] " rguenth at gcc dot gnu.org
2021-03-01  9:44 ` jakub at gcc dot gnu.org
2021-03-08 15:45 ` [Bug ipa/99309] " mpolacek at gcc dot gnu.org
2021-03-29 14:07 ` jakub at gcc dot gnu.org
2021-03-31 18:18 ` hubicka at gcc dot gnu.org
2021-03-31 18:29 ` jakub at gcc dot gnu.org
2021-03-31 18:46 ` hubicka at ucw dot cz
2021-04-08 12:02 ` rguenth at gcc dot gnu.org
2021-04-15  9:49 ` hubicka at gcc dot gnu.org
2022-03-24 13:59 ` [Bug ipa/99309] [10/11/12 " rguenth at gcc dot gnu.org
2022-06-28 10:43 ` [Bug ipa/99309] [10/11/12/13 " jakub at gcc dot gnu.org
2023-07-07 10:39 ` [Bug ipa/99309] [11/12/13/14 " rguenth at gcc dot gnu.org
2023-08-17  0:19 ` 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).