[Bug c++/89239] New: gcc claims that this expression is not constexpr

2019-02-07 Thread n.eugene536 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89239

Bug ID: 89239
   Summary: gcc claims that this expression is not constexpr
   Product: gcc
   Version: 8.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: n.eugene536 at gmail dot com
  Target Milestone: ---

Can't compile the following code:

enum E { e };

constexpr bool arr[1][1] = {{true}};

template
void check() { 
static_assert(arr[x][y], ""); 
}

int main() { 
check(); 
}

gcc says:
a.cpp: In instantiation of ‘void check() [with A x = (A)0; A y = (A)0]’:
a.cpp:11:17:   required from here
a.cpp:7:28: error: non-constant condition for static assertion
 static_assert(sz[x][y] == false, "");
a.cpp:7:28: error: accessing value of ‘sz’ through a ‘const bool’ glvalue in a
constant expression

g++ --version: 
g++ (Ubuntu 8.2.0-7ubuntu1) 8.2.0

[Bug libstdc++/88084] New: basic_string_view::copy doesn't use Traits::copy

2018-11-19 Thread n.eugene536 at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88084

Bug ID: 88084
   Summary: basic_string_view::copy doesn't use Traits::copy
   Product: gcc
   Version: 8.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: n.eugene536 at gmail dot com
  Target Milestone: ---

Target: x86_64-linux-gnu
gcc version 8.2.0 (Ubuntu 8.2.0-1ubuntu2~18.04)

Case: g++ a.cpp -std=c++17

struct my_trait : std::char_traits
{
static char* copy(char* dest, const char* src, std::size_t count) {
std::transform(src, src + count, dest, 
  [](char c) { return std::tolower(c); }
);

return dest;
}
};

int main() {
std::basic_string_view s2("AB");
char buf[3]{};
s2.copy(buf, 3);

std::cout << buf << std::endl;
}

The output is: AB
but expected: ab

In Standard: basic_string_view::copy has to be equivalent to traits::copy

[Bug c++/108242] New: '__FUNCTION__' was not declared when used inside a lambda declared inside a template function

2022-12-28 Thread n.eugene536 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108242

Bug ID: 108242
   Summary: '__FUNCTION__' was not declared when used inside a
lambda declared inside a template function
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: n.eugene536 at gmail dot com
  Target Milestone: ---

Target: x86_64-linux-gnu
Broken since gcc 12.1; works fine with gcc <= 11.3

g++ a.cpp -std=c++14

template
void my_fun()
{
auto fun = [&](auto res) {
static constexpr char const* fun_name = __FUNCTION__;
struct
{
constexpr const char* operator()() const { return fun_name; };
} t;
t();
};

fun(12);
}


int main() {
my_fun();
}


output: Compilation error
source>:8:63: error: '__FUNCTION__' was not declared in this scope
8 | constexpr const char* operator()() const { return fun_name;
};


expected: successful compilation

Works perfectly fine with clang