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

Compiling with --noCppExceptions option generates exception handling C++ code #23000

Open
demotomohiro opened this issue Nov 28, 2023 · 0 comments

Comments

@demotomohiro
Copy link
Contributor

Description

Compiling Nim code with cpp and --noCppExceptions generates C++ exception handling code.
If compiled with --passC:-fno-exceptions option to disable C++ exception, backend C++ compiler produces compile error.

testcpp.nim:

echo "hello"

Nim Version

Nim Compiler Version 2.1.1 [Linux: amd64]
Compiled at 2023-11-28
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: c31bbb0
active boot switches: -d:release

Current Output

$ nim cpp --exceptions:quirky --passC:-fno-exceptions --noCppExceptions testcpp.nim 
CC: ../nim-2.1.1/lib/system.nim
/tmp/nimcache123/testcpp/debug/@m..@snim-2.1.1@slib@ssystem.nim.cpp: In function 'void sysFatal__system_u4758(NimStringV2)':
/tmp/nimcache123/testcpp/debug/@m..@snim-2.1.1@slib@ssystem.nim.cpp:2641:27: error: exception handling disabled, use '-fexcepti
ons' to enable
 2641 |         catch (Exception* T3_) {
      |                           ^~~

Expected Output

With `--noCppExceptions` option, Nim doesn't produce C++ exception handling code and backend C++ compiler compiles generated Code without error even if C++ exception is disabled.

Possible Solution

No response

Additional Information

Compiling with following command line success without errors:

nim cpp --exceptions:quirky --passC:-fno-exceptions  testcpp.nim 
nim cpp --exceptions:quirky --passC:-fno-exceptions -d:noCppExceptions testcpp.nim 

It seems nocppexceptions command line option defines noCppExceptions in
https://github.com/nim-lang/Nim/blob/devel/compiler/commands.nim#L1060
but Nim generates exception handling C++ code.

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

No branches or pull requests

2 participants