简体   繁体   中英

Does the standard say anything about coexistence of exceptions and different calling conventions?

Like what if a function declared with a calling convention calls a normal(standard) function that throws? So the stack gets unwound and... what happens is, it would have to... I don't even know...

I would guess that it's all just UB. But that would be too sad. Probably only the compilers have something to say about that.

Does the standard actually say something about that?

The calling convention used and how exceptions work internally is implementation specific. For example, compilers on Linux and Windows use different calling conventions.

The C and C++ standards only specify how functions and exceptions should behave, but normally do not say much about how these features are to be implemented. Every combination of CPU, operating system and compiler may have their own way of implementing certain things.

If you want more information about exactly how the calling conventions are implemented in Linux and Windows on different CPUs/compilers, I recommend you read Agner Fog's Optimization Manual number 5. That manual also contains a chapter on exception handling/stack unwinding.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM