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

Generating getter method fails on access #50

Open
erikzenker opened this issue Oct 27, 2018 · 0 comments
Open

Generating getter method fails on access #50

erikzenker opened this issue Oct 27, 2018 · 0 comments

Comments

@erikzenker
Copy link

erikzenker commented Oct 27, 2018

I was using the latest trunk on the compiler explorer. Is this always the current version from git?

I tried to compile the following program:

#include <iostream>

template <typename T>
constexpr void getter(T origin){

    compiler.require(!origin.variables().empty(), "Need to have member variables");

    for...(auto o: origin.variables()){
        if(o.is_public()){
            o.make_private();
            __generate o;

            __generate __fragment struct {
                typename(o) idexpr("get_", o)() const {
                    return idexpr(o);
                }
            };
        }
    }
}

// USER CODE
class(getter) Test {
    public:
        int a;
};

constexpr {compiler.debug($Test);}

int main(){

    Test test;
    test.get_a();

    return 0;
}

This is the generated class:

class Test {

    int a;

public:

    int  get_a() const     {

        return a;

    }

}

But calling test.get_a(); leads to a compiler error:


#0 0x0000557524b49cea llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x1da0cea)

#1 0x0000557524b47b46 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x1d9eb46)

#2 0x0000557524b47c8c SignalHandler(int) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x1d9ec8c)

#3 0x00007fc4b2ce4890 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)

#4 0x000055752664a6af clang::Stmt::getLocStart() const (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x38a16af)

#5 0x0000557526594cd3 clang::Expr::getExprLoc() const (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x37ebcd3)

#6 0x0000557524d1d767 clang::CodeGen::ApplyDebugLocation::ApplyDebugLocation(clang::CodeGen::CodeGenFunction&, clang::Expr const*) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x1f74767)

#7 0x0000557524ec7efa clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x211eefa)

#8 0x0000557524ec87f9 clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x211f7f9)

#9 0x0000557524ec8226 clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x211f226)

#10 0x0000557524ecc49c clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x212349c)

#11 0x0000557524efeb59 (anonymous namespace)::ScalarExprEmitter::EmitLoadOfLValue(clang::Expr const*) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x2155b59)

#12 0x0000557524efe272 (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x2155272)

#13 0x0000557524f026c8 (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x21596c8)

#14 0x0000557524efdccd (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x2154ccd)

#15 0x0000557524efe660 clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x2155660)

#16 0x0000557524d4ab05 clang::CodeGen::CodeGenFunction::EmitReturnStmt(clang::ReturnStmt const&) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x1fa1b05)

#17 0x0000557524d4c8e5 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x1fa38e5)

#18 0x0000557524d4cd9f clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x1fa3d9f)

#19 0x0000557524d7f6c1 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::CodeGen::FunctionArgList&, clang::Stmt const*) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x1fd66c1)

#20 0x0000557524d85c5d clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x1fdcc5d)

#21 0x0000557524da0518 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x1ff7518)

#22 0x0000557524dc4ee0 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x201bee0)

#23 0x0000557524dc4fc9 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x201bfc9)

#24 0x0000557524dc5084 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x201c084)

#25 0x00005575253fa337 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x2651337)

#26 0x00005575253f8d05 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x264fd05)

#27 0x00005575258bacba clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x2b11cba)

#28 0x00005575253f8107 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x264f107)

#29 0x00005575250c9a16 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x2320a16)

#30 0x00005575250975ec clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x22ee5ec)

#31 0x000055752516db03 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x23c4b03)

#32 0x00005575236dc048 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x933048)

#33 0x00005575236686c6 main (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x8bf6c6)

#34 0x00007fc4b1b9db97 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b97)

#35 0x00005575236d9aba _start (/opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0+0x930aba)

Stack dump:

0.	Program arguments: /opt/compiler-explorer/clang-cppx-trunk-20181027/bin/clang-5.0 -cc1 -triple x86_64-unknown-linux-gnu -S -disable-free -disable-llvm-verifier -discard-value-names -main-file-name example.cpp -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -coverage-notes-file /tmp/compiler-explorer-compiler118927-10215-1tdhhf0.dm95f/output.gcno -resource-dir /opt/compiler-explorer/clang-cppx-trunk-20181027/lib/clang/5.0.0 -include cppx/meta -include cppx/compiler -I /opt/compiler-explorer/clang-cppx-trunk/include -c-isystem /usr/include/x86_64-linux-gnu -cxx-isystem /usr/include/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/clang-cppx-trunk-20181027/bin/../include/c++/v1 -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/clang-cppx-trunk-20181027/lib/clang/5.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++1z -fdeprecated-macro -fdebug-compilation-dir /compiler-explorer -ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -freflection -mllvm --x86-asm-syntax=intel -o /tmp/compiler-explorer-compiler118927-10215-1tdhhf0.dm95f/output.s -x c++ <source> 

1.	<eof> parser at end of file

2.	Per-file LLVM IR generation

3.	Generating code for declaration 'Test::get_a'

clang-5.0: error: unable to execute command: Segmentation fault (core dumped)

clang-5.0: error: clang frontend command failed due to signal (use -v to see invocation)

clang version 5.0.0 (https://github.com/asutton/clang.git dbca1f802cd36d5f7116b24487da29d1c64c3a0e) (https://github.com/llvm-mirror/llvm.git 40b1e969f9cb2a0c697e247435193fb006ef1311)

Target: x86_64-unknown-linux-gnu

Thread model: posix

InstalledDir: /opt/compiler-explorer/clang-cppx-trunk/bin

clang-5.0: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.

clang-5.0: note: diagnostic msg: 

********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:

Preprocessed source(s) and associated run script(s) are located at:

clang-5.0: note: diagnostic msg: /tmp/example-13e4ff.cpp

clang-5.0: note: diagnostic msg: /tmp/example-13e4ff.sh

clang-5.0: note: diagnostic msg: 

********************

Compiler returned: 254
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant