[Bug c++/105280] New: g++ does not raise sign-comapre in static_assert under some conditions

2022-04-14 Thread cfy1990 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105280

Bug ID: 105280
   Summary: g++ does not raise sign-comapre in static_assert under
some conditions
   Product: gcc
   Version: 11.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: cfy1990 at gmail dot com
  Target Milestone: ---

g++ does not raise sign-compare warnings in static_assert((-1 >= 1u) &&
T1::v, "");

Code link: https://godbolt.org/z/4GjT9f5oz
Compile arguments:  -O2 -std=c++11 -Wall -Wextra -Wconversion -Wsign-conversion
-Wunused-result  -Wsign-compare -Wlogical-not-parentheses -Wdouble-promotion

Code:

template
struct T1;

template<>
struct T1{
const static bool v=true;
};

template
void foo(__attribute__((unused)) T v){
// should generate warning, but not in g++
// clang works fine
static_assert((-1 >= 1u) && T1::v, "");

// codes works fine in gcc and clang
static_assert((-1 >= 1u) && T1::v, ""); // sign-compare warning

static_assert((-1 >= 1u), ""); // sign-compare warning

constexpr bool b = (-1 >= 1u) && T1::v; // sign-compare warning
static_assert(b, "");

static_assert((!3 > -1) && T1::v, ""); // logical-not-parentheses
warning
static_assert((1.0f*3.0 > 0) && T1::v, ""); // double-promotion warning
}

void bar(){
static_assert((-1 >= 1u) && T1::v, ""); // sign-compare
warning
foo(2u);
}

[Bug c++/105646] New: g++ does not raise xxx is used uninitialized warning under some conditions

2022-05-18 Thread cfy1990 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105646

Bug ID: 105646
   Summary: g++ does not raise xxx is used uninitialized warning
under some conditions
   Product: gcc
   Version: 12.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: cfy1990 at gmail dot com
  Target Milestone: ---

g++ version: g++ (Compiler-Explorer-Build-gcc--binutils-2.38) 12.1.0
Code link: https://godbolt.org/z/5MansKa5c
Compile arguments: -std=c++11  -Wextra -Wall -O2

Code:

int f1();
int f2(){
bool v2{v2}; // used uninitialized warning
auto const & a = f1();
return a;
}
int f3(){
auto const & a = f1();
bool v3{v3}; // no warning in g++, got uninitialized warning in clang
return a;
}

[Bug c++/105646] g++ does not raise xxx is used uninitialized warning under some conditions

2022-05-18 Thread cfy1990 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105646

--- Comment #1 from cfy1990 at gmail dot com ---
When compile without -O2, g++ will generate "'v3' may be used uninitialized"
warning.
code link: https://godbolt.org/z/r3sY4srx9