Closed main-- closed 7 years ago
I can reproduce the issue under Arch with latest libc++. I never tested building c++utilities with it because it also depends on iconv which is provided as part of libstdc++ under Arch and hence only available when using libc++. I'll try to find out what's going on.
And thanks for all the feedback so far.
Ok, it was actually very easy to find out the reason. You're using u16string
which does not seem to be supported at all. Using libstd++ you just get a runtime error instead:
terminate called after throwing an instance of 'std::bad_cast'
what(): std::bad_cast
The reason u16string
is not supported by std::basic_stringstream
is actually the reason I implemented the stringToNumber
and numberToString
functions for integral types on my own. However, I currently don't need such conversion for floating point types so I didn't provide an own implementation here.
So you don't just build the library to get Tag Editor, Syncthing Tray or any of my applications (because otherwise you wouldn't have run into this issue)?
Note that the code would work if you used wstring. Also note that using u16string is not a good idea and use of UTF-8 should be preferred whenever possible - especially in Unix environment. Of course that's only my opinion and sometimes not possible (hence I implemented the conversion for integral types and u16string).
So you don't just build the library to get Tag Editor, Syncthing Tray or any of my applications (because otherwise you wouldn't have run into this issue)?
Actually, that's exactly what I'm trying to do. To be precise, I'm just trying to create Rust bindings for tagparser.
The error originates here:
milliseconds = ConversionUtilities::stringToNumber<double>(parseWideString(buffer.get() + 1, m_dataSize - 1, dataEncoding), 10);
Where parseWideString
returns u16string
(unless I'm missing something obvious).
Ok, then that's the actual bug. Since it is only a runtime error with libstd++ I didn't noticed it. The line seems to be never tested (not in the test suite nor manually).
Should be fixed now in tagparser: https://github.com/Martchus/tagparser/commit/add833f87f25aef7821333d7f9349ce870d688ee
I'll definitely install standalone iconv to compile here everything with libc++, too.
To be precise, I'm just trying to create Rust bindings for tagparser.
Ah, now I get the "My C++ is unfortunately way too rusty" :-)
But of course thanks for trying to create Rust bindings. I checked how to create Python bindings some time ago and it looked like a huge effort. But maybe integration with Rust is a little bit easier.
I would recommend to only bind the high level API, though (MediaFileInfo, Tag, AbstractTrack, AbstractChapter and AbstractAttachment classes). Let me know if you make any process.
Is the error fixed with the mentioned commit so I can close the issue? I also compiled everything with libc++ and standalone iconv now and found no further problems so far.
By the way, if you have any questions about the library when creating those bindings, just ask.
It works now, thanks.
My C++ is unfortunately way too rusty to debug this but what I figured out is that this library fails to compile with
libc++
(llvm's standard library). GNUlibstdc++
works fine though.Reduced test case here.