Re: [Mingw-w64-public] [PATCH] stralign: cast ua_wcschr and ua_wcsrchr returns to wchar_t *

2017-04-06 Thread Liu Hao
On 2017/4/7 8:11, Norbert Pfeiler wrote: > Wasn’t LH_Mouse’s point that even if the warning is explicitly turned on it > wouldn’t be shown to the user? > > The situation for unions is different in C and C++: (I don’t think that > it’s just about constness changes anything) > http://stackoverflow.co

Re: [Mingw-w64-public] Problem using gcc in MSYS2 shell

2017-04-06 Thread Liu Hao
On 2017/4/7 0:56, Edward Diener wrote: > When trying to compile a project in MSYS2 using mingw-64/gcc I get this > error: > (... abridgement ...) This was an oversight. I replied with detailed information on msys2-users. -- Best regards, LH_Mouse

Re: [Mingw-w64-public] [PATCH] stralign: cast ua_wcschr and ua_wcsrchr returns to wchar_t *

2017-04-06 Thread Norbert Pfeiler
Wasn’t LH_Mouse’s point that even if the warning is explicitly turned on it wouldn’t be shown to the user? The situation for unions is different in C and C++: (I don’t think that it’s just about constness changes anything) http://stackoverflow.com/questions/11373203 Best, Norbert. Kai Tietz sch

[Mingw-w64-public] Problem using gcc in MSYS2 shell

2017-04-06 Thread Edward Diener
When trying to compile a project in MSYS2 using mingw-64/gcc I get this error: "Building shared library... x86_64-w64-mingw32-gcc -x c-header -DHAVE_CONFIG_H -Wall -Wextra -pedantic -pedantic-errors -Werror -Wwrite-strings -Wconversion -Wsign-conversion -Wsuggest-attribute=noreturn -Winvalid-pc

Re: [Mingw-w64-public] [PATCH] stralign: cast ua_wcschr and ua_wcsrchr returns to wchar_t *

2017-04-06 Thread Kai Tietz
2017-04-06 15:06 GMT+02:00 Liu Hao : > On 2017/4/6 20:47, Kai Tietz wrote: >> True. The reason why we prefer such patter is that it works in both >> languages as desired. Otherwise we would be in need to write >> different variants for the languages C/C++. This looks backward, and >> it still do

Re: [Mingw-w64-public] [PATCH] stralign: cast ua_wcschr and ua_wcsrchr returns to wchar_t *

2017-04-06 Thread Kai Tietz
2017-04-06 14:47 GMT+02:00 Kai Tietz : > 2017-04-06 13:38 GMT+02:00 Norbert Pfeiler > : >> I’m pretty sure that cast via union is UB in C++ whereas C-style casting >> away constness isn’t (only writing to the resulting object would be) but it >> may result in compilers issuing warnings about style

Re: [Mingw-w64-public] [PATCH] stralign: cast ua_wcschr and ua_wcsrchr returns to wchar_t *

2017-04-06 Thread Liu Hao
On 2017/4/6 20:47, Kai Tietz wrote: > True. The reason why we prefer such patter is that it works in both > languages as desired. Otherwise we would be in need to write > different variants for the languages C/C++. This looks backward, and > it still doesn't make sure that there might be warning

Re: [Mingw-w64-public] [PATCH] stralign: cast ua_wcschr and ua_wcsrchr returns to wchar_t *

2017-04-06 Thread Kai Tietz
2017-04-06 13:38 GMT+02:00 Norbert Pfeiler : > I’m pretty sure that cast via union is UB in C++ whereas C-style casting > away constness isn’t (only writing to the resulting object would be) but it > may result in compilers issuing warnings about style (because C++ has > const_cast). > > Best, Norb

Re: [Mingw-w64-public] [PATCH] stralign: cast ua_wcschr and ua_wcsrchr returns to wchar_t *

2017-04-06 Thread Norbert Pfeiler
I’m pretty sure that cast via union is UB in C++ whereas C-style casting away constness isn’t (only writing to the resulting object would be) but it may result in compilers issuing warnings about style (because C++ has const_cast). Best, Norbert. Kai Tietz schrieb am Do., 6. Apr. 2017 um 11:50 U

Re: [Mingw-w64-public] [PATCH] stralign: cast ua_wcschr and ua_wcsrchr returns to wchar_t *

2017-04-06 Thread Kai Tietz
A cast via union looks like this: type1 *foo(const type1 *my_const_ptr) { union { type1 *t1; const type1 *ct1; } v; v.ct1 = my_const_ptr; return v.t1; } The advantage of such a pattern is that no type conversion errors/warnings are shown. So for casting from const to none-const, this variant