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

ICE in g++ for template constructor with -mno-callee-assume-ss-data-segment #137

Open
asiekierka opened this issue Mar 11, 2023 · 3 comments

Comments

@asiekierka
Copy link

asiekierka commented Mar 11, 2023

$ ia16-elf-g++ -O0 -mno-callee-assume-ss-data-segment -MMD -MP -c -o obj/celeste.o src/celeste.c
src/celeste.c: In constructor '_fix32::_fix32(T)':
src/celeste.c:8:43: internal compiler error: Segmentation fault
         template <typename T> _fix32(T v) { *this = v; /* use operator= */ }
                                           ^
Please submit a full bug report,
with preprocessed source if appropriate.

Does not occur without -mno-callee-assume-ss-data-segment. Admittedly, this is a personal build of the toolchain.

Code (sourced from ccleste - this portion is WTFPL-licensed as per issue):

typedef long int32_t;

struct _fix32 {
        int32_t n;

        template <typename T> _fix32(T v) { *this = v; /* use operator= */ }
};
@tkchia
Copy link
Owner

tkchia commented Mar 11, 2023

Hello @asiekierka,

This is hard to fix unfortunately. Named address spaces are simply not supported by G++ at the moment — the C++ middle-end basically assumes that all pointers are compatible with void *. And -mno-callee-assume-ss-data-segment implicitly uses a named address space (__seg_ss).

I guess for the time being I should make gcc-ia16 show a clearer error message for such situations, rather than crashing on a null pointer...

Thank you!

tkchia added a commit that referenced this issue Mar 11, 2023
Partly addresses #137 .

Unfortunately named address spaces are simply not supported
by G++ at the moment — the C++ middle-end basically assumes
that all pointers are compatible with `void *`.  And
`-mno-callee-assume-ss-data-segment` implicitly uses a named
address space (`__seg_ss`).
@asiekierka
Copy link
Author

Ah, I understand now. I thought the problem is only at the level of code parsing, not throughout the entire middle-end. Thank you!

@asiekierka
Copy link
Author

I wonder: wouldn't adding support for the large memory model effectively work around this "cheaper" than making major patches to the C++ middle-end? That is to say, if void * is a far pointer...

Azhagen pushed a commit to Azhagen/gcc-ia16 that referenced this issue Jan 14, 2025
Partly addresses tkchia#137 .

Unfortunately named address spaces are simply not supported
by G++ at the moment — the C++ middle-end basically assumes
that all pointers are compatible with `void *`.  And
`-mno-callee-assume-ss-data-segment` implicitly uses a named
address space (`__seg_ss`).
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