Build failure on GCC/MinGW (MXE): std::ifstream constructor mismatch with Platform::filenameToUTF()
Maintainers usually reply within 4 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- cpp
- Domain
- build-system
Research direction
Start in src/OpenColorIO/transforms/FileTransform.cpp and inspect the std::ifstream construction using Platform::filenameToUTF(filepath). Build OpenColorIO with GCC/MinGW-w64 or MXE to reproduce the std::wstring overload failure, then verify that the path handling compiles and works across the affected configurations.
Written by the indexing model from the issue text.
Description
Description
OpenColorIO 2.5.1 fails to compile under GCC / MinGW-w64 (including MXE cross builds) due to inconsistent file path type handling in Platform::filenameToUTF() when used with std::ifstream in FileTransform.cpp.
The failure occurs when constructing a std::ifstream from the result of Platform::filenameToUTF(filepath), where the returned type may vary between std::string and std::wstring depending on build configuration (_WIN32 && UNICODE).
This leads to template overload resolution failures under GCC/libstdc++ when a std::wstring is involved in std::ifstream construction.
Error observed (GCC / libstdc++)
error: no matching function for call to
std::basic_ifstream<char>::basic_ifstream(const std::wstring, std::ios_base::openmode)
Affected code src/OpenColorIO/transforms/FileTransform.cpp:
std::ifstream(Platform::filenameToUTF(filepath), mode)
Root cause
Platform::filenameToUTF()is conditionally typed:std::wstringon _WIN32 && UNICODEstd::stringotherwisestd::ifstreamconstruction fromstd::wstringis not consistently supported across standard library implementations- GCC/libstdc++ rejects this usage, while MSVC may accept it depending on STL implementation details
- This creates a portability issue in file I/O path handling
Impact
- Breaks MXE / MinGW-w64 cross compilation
- Causes divergence between MSVC and GCC builds
- Introduces non-portable file path handling in core I/O utilities
Suggested fix
Avoid passing platform-dependent string types directly into std::ifstream construction.
This is the C++17-compatible solution that worked:
auto path = Platform::filenameToUTF(filepath);
return std::make_unique<std::ifstream>(path.c_str(), mode);
- Dominant language
- C++
- Stars
- 2.1k
- Forks
- 503
- Avg merge
- 8d 3h
- Merged PRs (30d)
- 10
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AcademySoftwareFoundation/OpenColorIO
-
Inconsistent run-time library usage for locale handling breaks GPU code generation on some systems.Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
AcademySoftwareFoundation/OpenColorIO#2351 · 2 comments ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
AcademySoftwareFoundation/OpenColorIO#2340 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
AcademySoftwareFoundation/OpenColorIO#2329 ·
Maintainers usually reply within 4 days
-
Documentation
Difficulty 1/5 Under an hour Newbie friendliness 72/100
AcademySoftwareFoundation/OpenColorIO#2280 · 1 comment ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
AcademySoftwareFoundation/OpenColorIO#2277 ·
Maintainers usually reply within 4 days
All issues in AcademySoftwareFoundation/OpenColorIO
Similar issues
-
bug chart-audit
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 1 day
-
HasBacktrace Priority-Critical
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
azerothcore/azerothcore-wotlk#27921 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
yhirose/cpp-peglib#344 ·