[Bug c++/66170] Bogus warning with -Wsign-conversion when using static_cast on an int

2016-10-13 Thread sir.vestnik at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66170

Sergey Vidyuk  changed:

   What|Removed |Added

 CC||sir.vestnik at gmail dot com

--- Comment #1 from Sergey Vidyuk  ---
I have similair issue with gcc-6.2

[vestnik@VestniK-laptop C++]$ cat fasttest.cpp 
#include 
#include 

void foo(const std::vector vec, const int idx) {
if (idx < 0 || vec.size() <= static_cast(idx))
{
std::cout << "No such index\n";
return;
}
std::cout << "Valid index\n";
}

int main() {
foo({1, 2, 3, 4 ,5}, 6);
return 0;
}
[vestnik@VestniK-laptop C++]$ g++ -std=c++11 -Wsign-conversion -Wall -Werror
fasttest.cpp -o fasttest
fasttest.cpp: In function 'void foo(std::vector, int)':
fasttest.cpp:5:31: error: conversion to 'std::vector::size_type {aka long
unsigned int}' from 'const int' may change the sign of the result
[-Werror=sign-conversion]
  if (idx < 0 || vec.size() <= static_cast(idx))
   ^~~~
cc1plus: all warnings being treated as errors
[vestnik@VestniK-laptop C++]$ g++ --version
g++ (GCC) 6.2.1 20160830
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


It looks like static_cast type was incorrectly treated as const int instead of
size_t. Changing static_cast(idx) to static_cast(idx)
silences diagnostics but such fix looks lihe a strange hack.

[Bug libstdc++/70483] New: string_view::compare and coparision operators are not constexpr

2016-03-31 Thread sir.vestnik at gmail dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70483

Bug ID: 70483
   Summary: string_view::compare and coparision operators are not
constexpr
   Product: gcc
   Version: 5.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: sir.vestnik at gmail dot com
  Target Milestone: ---

libstdc++ std::experimental::basic_string_view implementation mising a lot of
constexpr specifications (according to the n4480) for example commented out
static assert here
https://github.com/VestniK/cpp-metainf/blob/master/pretty_func_parse/member_name.h
is valid and can be compiled with clang libc++ but fails to compile with gcc
libstdc++