fault when pushing lambda to std::stack

Basic problem

here is the faulting code

std::cout << "tokenType 0" << std::endl;
noSuchType::error.push([](noSuchType e) -> int {return 0;});
std::cout << "tokenType 1" << std::endl;

and here is the output it produces

tokenType 0
stack trace: 
./src/main.cxx:60 in HANDLER_SIGSEGV(int)
/usr/include/c++/14.1.1/bits/stl_construct.h:97 in decltype (::new ((void*)(0)) int (*std::construct_at<int (*)(issues::noSuchType), int (*)(issues::noSuchType)>(int (**)(issues::noSuchType), int (*&&)(issues::noSuchType)))(issues::noSuchType)((declval<int (*)(issues::noSuchType)>)()))
/usr/include/c++/14.1.1/bits/alloc_traits.h:538 in void std::allocator_traits<std::allocator<int (*)(issues::noSuchType)> >::construct<int (*)(issues::noSuchType), int (*)(issues::noSuchType)>(std::allocator<int (*)(issues::noSuchType)>&, int (**)(issues::noSuchType), int (*&&)(issues::noSuchType))
/usr/include/c++/14.1.1/bits/deque.tcc:178 in int (*&std::deque<int (*)(issues::noSuchType), std::allocator<int (*)(issues::noSuchType)> >::emplace_back<int (*)(issues::noSuchType)>(int (*&&)(issues::noSuchType)))(issues::noSuchType)
/usr/include/c++/14.1.1/bits/stl_deque.h:1554 in std::deque<int (*)(issues::noSuchType), std::allocator<int (*)(issues::noSuchType)> >::push_back(int (*&&)(issues::noSuchType))
/usr/include/c++/14.1.1/bits/stl_stack.h:264 in std::stack<int (*)(issues::noSuchType), std::deque<int (*)(issues::noSuchType), std::allocator<int (*)(issues::noSuchType)> > >::push(int (*&&)(issues::noSuchType))
./src/class_line.cxx:289 in tokenType(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)
./src/class_line.cxx:596 in line::nextToken(bool)
./src/parser.cxx:1710 in parseline(line&, bool&, bool&, std::vector<line, std::allocator<line> >&, unsigned long&)
./src/parser.cxx:1094 in parse(std::vector<line, std::allocator<line> >)
./src/parser.cxx:1325 in parseline(line&, bool&, bool&, std::vector<line, std::allocator<line> >&, unsigned long&)
./src/parser.cxx:1094 in parse(std::vector<line, std::allocator<line> >)
./src/main.cxx:262 in main

but if i put in return 1 instead of return 0 like this:

std::cout << "tokenType 0" << std::endl;
noSuchType::error.push([](noSuchType e) -> int {return 1;});
std::cout << "tokenType 1" << std::endl;

i get the expected output:

tokenType 0
tokenType 1

more relevant code for context.

code that may call the functions inside noSuchType::error

    template<typename issueType>
    void invoke(issueType e)
    {
        std::cout << "invoke<" << typeid(issueType).name() <<">"<< std::endl;
        switch(e.Action)
        {
            case(action::error):
            {
                //std::cout << "invoking: " << issueType::error.top() << std::endl;
                if(issueType::error.top()(e) == 1)
                    throw e;
                break;
            }
            case(action::warning):
            {
                //std::cout << "invoking: " << issueType::warn.top() << std::endl;
                issueType::warn.top()(e);
                break;
            }
            case(action::info):
            {
                std::cout << "invoking: " << issueType::info.top() << std::endl;
                issueType::info.top()(e);
                break;
            }
        }
    }

noSuchType class (inside issues.hxx)

    class fatal : public issue {
    public:
        const static action Action = action::error;
    };
    class noSuchType : public fatal {
    public:
        std::string name;
        static std::stack<void(*)(noSuchType e)> info;
        static std::stack<void(*)(noSuchType e)> warn;
        static std::stack<int(*)(noSuchType e)> error;
        noSuchType(ISSUES_CTOR_ARGS, std::string name)
            :name(name){ISSUES_CTOR_INIT;invoke(*this);}
    };
    #ifdef ISSUES_CXX
        std::stack<void(*)(noSuchType e)> noSuchType::info;
        std::stack<void(*)(noSuchType e)> noSuchType::warn;
        std::stack<int(*)(noSuchType e)> noSuchType::error;
    #endif

issues.cxx

#define ISSUES_CXX
#include <issues.hxx>

namespace issues
{
    uint64_t ErrorCount = 0;

    void changeGroupAction(std::string name, action Action)
    {
        if(name == "absolute-memory")
        {
            absoluteMemoryStorage::Action = Action;
        }
        else if(name == "cpl")
        {
            insufficientPrivilegeLevel::Action = Action;
        }
        else if(name == "unimplemented")
        {
            unimplementedDebugInfo::Action = Action;
        }
    }
}

System, cpu & toolchain

compiler options

-std=c++20 -g -Wno-write-strings -rdynamic -pedantic -Wno-multichar -Wunreachable-code -Wno-literal-suffix -Wno-pointer-arith -fpermissive -Iinc/ -g -c -fdiagnostics-color -MD -MF <depency file> -o <output file>

uname -a

Linux hostname 6.1.92-1-MANJARO #1 SMP PREEMPT_DYNAMIC Mon May 27 03:37:00 UTC 2024 x86_64 GNU/Linux

lscpu

Architecture:             x86_64
  CPU op-mode(s):         32-bit, 64-bit
  Address sizes:          48 bits physical, 48 bits virtual
  Byte Order:             Little Endian
CPU(s):                   8
  On-line CPU(s) list:    0-7
Vendor ID:                AuthenticAMD
  Model name:             AMD FX(tm)-8350 Eight-Core Processor
    CPU family:           21
    Model:                2
    Thread(s) per core:   2
    Core(s) per socket:   4
    Socket(s):            1
    Stepping:             0
    Frequency boost:      enabled
    CPU(s) scaling MHz:   54%
    CPU max MHz:          4000,0000
    CPU min MHz:          1400,0000
    BogoMIPS:             8038,57
    Flags:                fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm 
                          constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 popcnt aes xsave avx f16c l
                          ahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs xop skinit wdt fma4 tce nodeid_msr tbm topoext perfctr_core 
                          perfctr_nb cpb hw_pstate ssbd ibpb vmmcall bmi1 arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthre
                          shold

g++ -v

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/14.1.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.1.1 20240522 (GCC)

Debugging

  • I have checked if this is actually an issue inside issues::invoke and the stack trace is just messed up, but that does not appear to be the case.

  • The output that results from return 0 also occurs for return 2

  • return 0,return 1 and return 2 all compile without any warnings related to the code in question

I can obviously provide more context if necessary but i feel like this should suffice.
I Apologize for any spelling mistakes or grammatical errors, English is not my first language.
Thanks for you help in advance.

New contributor

IDontLikeSand is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật