[Bug sanitizer/97067] New: UBSAN: False positive maybe-uninitialized

2020-09-16 Thread vincent.lebourlot at starqube dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97067

Bug ID: 97067
   Summary: UBSAN: False positive maybe-uninitialized
   Product: gcc
   Version: 11.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: sanitizer
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vincent.lebourlot at starqube dot com
CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
jakub at gcc dot gnu.org, kcc at gcc dot gnu.org, marxin at 
gcc dot gnu.org
  Target Milestone: ---

Compiling with -Wall -fsanitize=undefined the following code causes a false
positive:

```
void nothing(){return;}
int toto=[](){nothing();return 0;}();
int main(){return 0;}


warnings are:

main.cpp: In function ‘void __static_initialization_and_destruction_0(int,
int)’:
main.cpp:3:35: warning: ‘’ may be used uninitialized
[-Wmaybe-uninitialized]
3 | int toto=[](){nothing();return 0;}();
  |  ~^~
main.cpp:3:10: note: by argument 1 of type ‘const*’ to ‘’
declared here
3 | int toto=[](){nothing();return 0;}();
  |  ^
main.cpp:3:10: note: ‘’ declared here
3 | int toto=[](){nothing();return 0;}();
  |  ^

[Bug c++/109888] New: GCC 13 Fails to Compile Code with Explicit Constructor for std::array in Template Class

2023-05-17 Thread vincent.lebourlot at starqube dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109888

Bug ID: 109888
   Summary: GCC 13 Fails to Compile Code with Explicit Constructor
for std::array in Template Class
   Product: gcc
   Version: 13.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vincent.lebourlot at starqube dot com
  Target Milestone: ---

In a C++ codebase, a class String is defined with an explicit constructor that
takes a variable number of arguments and constructs a std::array from them.
This constructor is being called when creating a std::pair in a
function call.

While this code compiles successfully with GCC 12, it fails to compile with GCC
13. The error messages indicate that the std::array must be initialized with a
brace-enclosed initializer, which is not what's happening when forwarding the
arguments to the std::array's constructor.

This issue seems to be specific to GCC 13 and does not occur in GCC 12. It's
unclear whether this is due to changes in the C++ standard or in GCC's
implementation of the standard. The code snippet that reproduces this issue is
provided below:

#include 
#include 
#include 
#include 
#include 

class String {
public:
templateString(const char(&s)[n])noexcept:value(){
if constexpr(n<=16){
std::memcpy(value.data(),s,n);}
else{value=std::array{};}}
template...>, int> = 0>
explicit String(Args&&... args) : value(std::forward(args)...) {}
private:
std::arrayvalue;
};

int main() {
auto check=[&](std::vector>textInputs){};
check({{{"Hello", "World"}, {"Foo", "Bar"}}});
return 0;
}


And here's the error message:

test.cpp: In function ‘int main()’:
test.cpp:20:10: error: converting to ‘const String’ from initializer list would
use explicit constructor ‘String::String(Args&& ...) [with Args = {const char
(&)[6], const char (&)[6]}; typename
std::enable_if, std::allocator >, Args>...>, int>::type
 = 0]’
   20 | check({{{"Hello", "World"}, {"Foo", "Bar"}}});
  | ~^~~~
test.cpp:20:10: error: converting to ‘const String’ from initializer list would
use explicit constructor ‘String::String(Args&& ...) [with Args = {const char
(&)[4], const char (&)[4]}; typename
std::enable_if, std::allocator >, Args>...>, int>::type
 = 0]’
test.cpp: In instantiation of ‘String::String(Args&& ...) [with Args = {const
char (&)[6], const char (&)[6]}; typename
std::enable_if, std::allocator >, Args>...>, int>::type
 = 0]’:
test.cpp:20:10:   required from here
test.cpp:12:39: error: no matching function for call to ‘std::array::array(const char [6], const char [6])’
   12 | explicit String(Args&&... args) :
value(std::forward(args)...) {}
  |  
^~
In file included from test.cpp:3:
/usr/local/gcc/gcc-13/include/c++/13.1.0/array:94:12: note: candidate:
‘std::array::array()’
   94 | struct array
  |^
/usr/local/gcc/gcc-13/include/c++/13.1.0/array:94:12: note:   candidate expects
0 arguments, 2 provided
/usr/local/gcc/gcc-13/include/c++/13.1.0/array:94:12: note: candidate:
‘constexpr std::array::array(const std::array&)’
/usr/local/gcc/gcc-13/include/c++/13.1.0/array:94:12: note:   candidate expects
1 argument, 2 provided
/usr/local/gcc/gcc-13/include/c++/13.1.0/array:94:12: note: candidate:
‘constexpr std::array::array(std::array&&)’
/usr/local/gcc/gcc-13/include/c++/13.1.0/array:94:12: note:   candidate expects
1 argument, 2 provided
test.cpp: In instantiation of ‘String::String(Args&& ...) [with Args = {const
char (&)[4], const char (&)[4]}; typename
std::enable_if, std::allocator >, Args>...>, int>::type
 = 0]’:
test.cpp:20:10:   required from here
test.cpp:12:39: error: no matching function for call to ‘std::array::array(const char [4], const char [4])’
   12 | explicit String(Args&&... args) :
value(std::forward(args)...) {}
  |  
^~
/usr/local/gcc/gcc-13/include/c++/13.1.0/array:94:12: note: candidate:
‘std::array::array()’
   94 | struct array
  |^
/usr/local/gcc/gcc-13/include/c++/13.1.0/array:94:12: note:   candidate expects
0 arguments, 2 provided
/usr/local/gcc/gcc-13/include/c++/13.1.0/array:94:12: note: candidate:
‘constexpr std::array::array(const std::array&)’
/usr/local/gcc/gcc-13/include/c++/13.1.0/array:94:12: note:   candidate expects
1 argument, 2 provided
/usr/local/gcc/gcc-13/include/c++/13.1.0/array:94:12: note: candidate:
‘constexpr std::array::array(std::array&&)’
/usr/local/gcc/gcc-13/include/c++/13.1.0/array:94:12: note:   candidate expects
1 argument, 2 provided

[Bug c++/115941] New: g++ compiler version 15 doesn't fails to build when g++ 12 does (may be related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109247)

2024-07-15 Thread vincent.lebourlot at starqube dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115941

Bug ID: 115941
   Summary: g++ compiler version 15 doesn't fails to build when
g++ 12 does (may be related to
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109247)
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vincent.lebourlot at starqube dot com
  Target Milestone: ---

Here is a minimal code that doesn't compile with gcc 15 trunk version 

```
gcc-15/bin/g++ --version
g++ (GCC) 15.0.0 20240715 (experimental)
Copyright (C) 2024 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.

```

```cpp
#include 
#include 
#include 
#include 

class piece{
public:
std::string_view view;
piece(const void*)=delete;
templateexplicit piece(const
char(&s)[n])noexcept:view(s,n-1){}
};

class NLargeStringPiece{};

class string{
private:
std::arrayvalue;
public:
string(const void*)=delete;
templatestring(const char(&s)[n])noexcept:value(){}
templateexplicit string(const
Args&...args)requires(std::conjunction_v,std::is_constructible>...>):value(){}

};

int main() noexcept{
std::vector>foo{{{"foo","foo"}}};
   
std::vector>bar{{{"bar","bar"},{"bar","bar"}}};
return 0;
}
```

and the error being printed: 

```
 ❯/usr/local/gcc/gcc-12.3/bin/g++
/home/lebourlot/gcc15/StarQube/Sources/Scratch/ToolScratch.cpp -o
/home/lebourlot/gcc15/StarQube/Sources/Scratch/Scratch.exe -std=c++2b -g -Wall
-fPIC -pie -static-libstdc++ -gdwarf-4 -pthread -maes -msse4.1 -isystem
/usr/local/include
 ❯/usr/local/gcc/gcc-15/bin/g++
/home/lebourlot/gcc15/StarQube/Sources/Scratch/ToolScratch.cpp -o
/home/lebourlot/gcc15/StarQube/Sources/Scratch/Scratch.exe -std=c++2b -g -Wall
-fPIC -pie -static-libstdc++ -gdwarf-4 -pthread -maes -msse4.1 -isystem
/usr/local/include
/home/lebourlot/gcc15/StarQube/Sources/Scratch/ToolScratch.cpp: In function
‘int main()’:
/home/lebourlot/gcc15/StarQube/Sources/Scratch/ToolScratch.cpp:27:87: error:
converting to ‘string’ from initializer list would use explicit constructor
‘string::string(const Args& ...) requires 
conjunction_v,
std::is_constructible >...> [with Args = {char [4],
char [4]}]’
   27 |
std::vector>bar{{{"bar","bar"},{"bar","bar"}}};
  |
  ^
/home/lebourlot/gcc15/StarQube/Sources/Scratch/ToolScratch.cpp:21:51: note:
‘string::string(const Args& ...) requires 
conjunction_v,
std::is_constructible >...> [with Args = {char [4],
char [4]}]’ declared here
   21 | templateexplicit string(const
Args&...args)requires(std::conjunction_v,std::is_constructible>...>):value(){}
  |   ^~
/home/lebourlot/gcc15/StarQube/Sources/Scratch/ToolScratch.cpp:27:87: error:
converting to ‘string’ from initializer list would use explicit constructor
‘string::string(const Args& ...) requires 
conjunction_v,
std::is_constructible >...> [with Args = {char [4],
char [4]}]’
   27 |
std::vector>bar{{{"bar","bar"},{"bar","bar"}}};
  |
  ^
/home/lebourlot/gcc15/StarQube/Sources/Scratch/ToolScratch.cpp:21:51: note:
‘string::string(const Args& ...) requires 
conjunction_v,
std::is_constructible >...> [with Args = {char [4],
char [4]}]’ declared here
   21 | templateexplicit string(const
Args&...args)requires(std::conjunction_v,std::is_constructible>...>):value(){}
  |   ^~
[1]876699 exit 1 /usr/local/gcc/gcc-15/bin/g++  -o  -std=c++2b -g -Wall
-fPIC -pie  -gdwarf-4 
```

[Bug c++/115941] g++ compiler version 15 doesn't fails to build when g++ 12 does (may be related to PR 109247)

2024-07-15 Thread vincent.lebourlot at starqube dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115941

--- Comment #4 from vincent.lebourlot at starqube dot com ---
Thank you very much for the quick answer. This can be closed then. 

If I understand correctly, as this follows the standard, it won't ever be
accepted anymore in gcc despite clang accepting it? 

Thanks for your time.
Bests

[Bug libstdc++/117394] evil regex causes a stack overflow and a crash

2024-11-01 Thread vincent.lebourlot at starqube dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117394

--- Comment #2 from vincent.lebourlot at starqube dot com ---
fair enough. Any chance this might be looked at at some point? llvm doesn't
seem to have such a problem on that regex. 
Cheers

[Bug libstdc++/117394] New: evil regex causes a stack overflow and a crash

2024-11-01 Thread vincent.lebourlot at starqube dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117394

Bug ID: 117394
   Summary: evil regex causes a stack overflow and a crash
   Product: gcc
   Version: 15.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: vincent.lebourlot at starqube dot com
  Target Milestone: ---

Following code causes a crash when compiled with g++ 15 (gcc (GCC) 15.0.0
20240715 (experimental))

#include 
#include 

int main(){
std::string s(15000,'a');
std::regex r3("a(\\r|.)*");
std::regex_match(s.begin(),s.end(),r3);
return 0;
}