Hi all,

I might have found a bug in gcc or mingw, but I'm not really sure.

For the following version:
g++ (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0

A short example:

#include <cstddef>
#include <cstdio>
#include <cstdint>
#include <array>

int main()
{
  const char istr[] = "Hello";
  std::array<char16_t, std::char_traits<char>::length( istr )> str16;

  return 0;
}

Now the compile step:

g++ -c -std=c++17 -pedantic -Wextra -Wlogical-op test.cpp
In file included from 
C:/dev/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/string:40,
                 from 
C:/dev/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/stdexcept:39,
                 from 
C:/dev/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/array:39,
                 from test.cpp:4:
C:/dev/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/char_traits.h:
 
In function 'int main()':
test.cpp:9:54:   in 'constexpr' expansion of 
'std::char_traits<char>::length(((const char*)(& istr)))'
C:/dev/x86_64-8.1.0-release-win32-seh-rt_v6-rev0/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/bits/char_traits.h:320:25:
 
error: '__builtin_strlen(((const char_type*)(& istr)))' is not a constant 
expression
  return __builtin_strlen(__s);
         ~~~~~~~~~~~~~~~~^~~~~
test.cpp:9:54: note: in template argument for type 'long long unsigned int'
   std::array<char16_t, std::char_traits<char>::length( istr )> str16;
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
mingw32-make.exe: *** [C:\dev\mydesign\SW\C++\win32\array_test\test.mak:9: 
test.o] Error 1

This shouldn't be, right? As it succesfully selects the constexpr function 
variant for the second template argument it should also work further down, I 
believe.

Best regards,
Maarten Verhage



_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to