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

Internal compiler error when building with MinGW on Windows #1531

Closed
sakiryu opened this issue Jan 22, 2020 · 5 comments
Closed

Internal compiler error when building with MinGW on Windows #1531

sakiryu opened this issue Jan 22, 2020 · 5 comments

Comments

@sakiryu
Copy link

sakiryu commented Jan 22, 2020

When i tried to build a console app using the header-only version, got the following error:

In file included from ../fmt/include/fmt/format.h:3536,
from ../main.cpp:4:
../fmt/include/fmt/format-inl.h: In function 'int fmt::v6::internal::snprintf_float(T, int, fmt::v6::internal::float_specs, fmt::v6::internal::buffer&)':
../fmt/include/fmt/format-inl.h:69:25: internal compiler error: Segmentation fault
#define FMT_SNPRINTF snprintf
../fmt/include/fmt/format-inl.h:1163:25: note: in expansion of macro 'FMT_SNPRINTF'
auto snprintf_ptr = FMT_SNPRINTF;

This was caused by the snprintf assignment to snprintf_ptr variable. I was able to build successfully after a few changes:

Line 64, change:
#define FMT_SNPRINTF snprintf

To:
#if defined(__MINGW32__)
int (*psnprintf)(char*, std::size_t, char const*, ...) = std::snprintf;
#define FMT_SNPRINTF psnprintf
#else
#define FMT_SNPRINTF snprintf
#endif

@vitaut
Copy link
Contributor

vitaut commented Jan 22, 2020

Does changing

auto snprintf_ptr = FMT_SNPRINTF;

to

int (*snprintf_ptr)(char*, std::size_t, char const*, ...) = FMT_SNPRINTF;

and similarly in

auto snprintf_ptr = FMT_SNPRINTF;
also "fix" the internal compiler error?

@sakiryu
Copy link
Author

sakiryu commented Jan 22, 2020

Yes, it works as well.

@vitaut
Copy link
Contributor

vitaut commented Jan 22, 2020

Great, thanks for checking. Could you submit a PR with these two small changes and a comment that it's a workaround for MinGW?

@sakiryu
Copy link
Author

sakiryu commented Jan 22, 2020

Sure

@vitaut vitaut changed the title Segmentation fault when building with MinGW on Windows Internal compiler error when building with MinGW on Windows Jan 23, 2020
@vitaut
Copy link
Contributor

vitaut commented Jan 23, 2020

@ryusakki, could you also post your compiler version here for future reference?

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

2 participants