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

throw doesn't work as expected with xeus-cpp #254

Open
anutosh491 opened this issue Feb 7, 2025 · 2 comments
Open

throw doesn't work as expected with xeus-cpp #254

anutosh491 opened this issue Feb 7, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@anutosh491
Copy link
Collaborator

I am guessing something changed in clang/clang-repl/llvm after version 17

We could achieve this I think using CppInterOp 1.3.0 (part of our example notebook)

Image

I know throw basically should end "erroring" out ..... but we would prefer something like the above where we error out through the console and not our kernel crashing and restarting

Image
@anutosh491 anutosh491 added the bug Something isn't working label Feb 7, 2025
@github-actions github-actions bot added the Needs triage Used in auto labelling of new issues label Feb 7, 2025
@anutosh491 anutosh491 removed the Needs triage Used in auto labelling of new issues label Feb 7, 2025
@anutosh491
Copy link
Collaborator Author

anutosh491 commented Feb 13, 2025

I'm sorry, this still works

Image

One might ask why do I see the kernel restarting above ?
Ans: Because I am on Apple Mac M2 and there is something not correct about how exception handling works with any Mac ARM device (llvm/llvm-project#92121)

@anutosh491
Copy link
Collaborator Author

That being said there is still an error here !

I shall be changing the issue title to make a note of it.

This was discovered while playing around with throw. Let's say we miss out of the placeholder from the above catch block (basically any sort of wrong syntax)... this would end up seeing this

clang-repl> #include <stdio.h>            
clang-repl> try { throw 1; } catch { printf("Caught exception\n"); }
In file included from <<< inputs >>>:1:
input_line_2:1:23: error: expected '('
    1 | try { throw 1; } catch { printf("Caught exception\n"); }
      |                       ^
      |                       (
clang-repl: /home/abhinav/Desktop/Coding/CERN_HSF_Compiler_Research/llvm-project/clang/lib/AST/DeclBase.cpp:1737: void clang::DeclContext::addHiddenDecl(clang::Decl*): Assertion `D->getLexicalDeclContext() == this && "Decl inserted into wrong lexical context"' failed.
Aborted (core dumped)

So this segfaults and crashes the clang-repl instance. Whereas I would expected it to gracefully fail giving back a parsing error. Just like what I see below

clang-repl> #include <iostream>
clang-repl> std::cut << "hello";
In file included from <<< inputs >>>:1:
input_line_2:1:6: error: no member named 'cut' in namespace 'std'; did you mean 'cout'?
    1 | std::cut << "hello";
      | ~~~~~^~~
      |      cout
/Users/anutosh491/micromamba/envs/clang-repl-env/bin/../include/c++/v1/iostream:54:42: note: 'cout' declared here
   54 | extern _LIBCPP_EXPORTED_FROM_ABI ostream cout;
      |                                          ^
error: Parsing failed.

@anutosh491 anutosh491 changed the title throw no longer working with xeus-cpp throw doesn't work as expected with xeus-cpp Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant