[Bug c/108518] New: Format-overflow warning using `*.s` directive with null but zero-length string

2023-01-24 Thread aaron at aarongraham dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108518

Bug ID: 108518
   Summary: Format-overflow warning using `*.s` directive with
null but zero-length string
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: aaron at aarongraham dot com
  Target Milestone: ---

https://godbolt.org/z/YGra91Woa

#include 

int main() {
// This causes a format-overflow warning, but it
// should not warn if size() is 0
printf("%.*s\n", 0, (char*)0);
}

The warning is:

: In function 'int main()':
:6:13: warning: '%.*s' directive argument is null [-Wformat-overflow=]
6 | printf("%.*s\n", 0, (char*)0);
  | ^~~~

I see this commonly when using std::string_view with printf. In cases where it
knows that you're passing a default-constructed string_view it produces this
warning.

It should not produce this warning if the length being printed is 0.

[Bug libstdc++/106802] New: Comparators in don't work with orderings in

2022-09-01 Thread aaron at aarongraham dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106802

Bug ID: 106802
   Summary: Comparators in  don't work with orderings
in 
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: aaron at aarongraham dot com
  Target Milestone: ---

gcc does not allow this to compile:

std::less<>{}(std::strong_ordering::less, 0);

Even though `std::strong_ordering::less < 0` is perfectly legal and
well-formed.

It will compile this (but clang will not):

std::less<>{}(std::strong_ordering::less, nullptr);

Godbolt link: https://gcc.godbolt.org/z/9ed16KbhP

[Bug c++/100322] New: Switching from std=c++17 to std=c++20 causes performance regression in relationals

2021-04-28 Thread aaron at aarongraham dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100322

Bug ID: 100322
   Summary: Switching from std=c++17 to std=c++20 causes
performance regression in relationals
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: aaron at aarongraham dot com
  Target Milestone: ---

Experiment here: https://godbolt.org/z/PT73cn5e5

#include 

using clk = std::chrono::steady_clock;
bool compare_count(clk::duration a, clk::duration b) {
return a.count() > b.count();
}
bool compare(clk::duration a, clk::duration b) {
return a > b;
}

Compiling with -std=c++17 I get:

_Z13compare_countNSt6chrono8durationIxSt5ratioILx1ELx10S3_:
cmp r2, r0
sbcsr3, r3, r1
ite lt
movlt   r0, #1
movge   r0, #0
bx  lr
_Z7compareNSt6chrono8durationIxSt5ratioILx1ELx10S3_:
cmp r2, r0
sbcsr3, r3, r1
ite lt
movlt   r0, #1
movge   r0, #0
bx  lr

Compiling with -std=c++20 I get:

_Z13compare_countNSt6chrono8durationIxSt5ratioILx1ELx10S3_:
cmp r2, r0
sbcsr3, r3, r1
ite lt
movlt   r0, #1
movge   r0, #0
bx  lr
_Z7compareNSt6chrono8durationIxSt5ratioILx1ELx10S3_:
cmp r1, r3
it  eq
cmpeq   r0, r2
beq .L4
cmp r0, r2
sbcsr3, r1, r3
bge .L5
mov r0, #-1
.L3:
cmp r0, #0
ite le
movle   r0, #0
movgt   r0, #1
bx  lr
.L4:
movsr0, #0
b   .L3
.L5:
movsr0, #1
b   .L3

(Note that clang doesn't have this problem)

[Bug libstdc++/100259] New: ODR violations in

2021-04-25 Thread aaron at aarongraham dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100259

Bug ID: 100259
   Summary: ODR violations in 
   Product: gcc
   Version: 12.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: libstdc++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: aaron at aarongraham dot com
  Target Milestone: ---

Current implementation in  has functions that violate
ODR:

  std::experimental::net::ip::make_error_code
  std::experimental::net::ip::make_error_condition
  std::experimental::net::ip::make_network_v4

It seems these should be inline and/or constexpr. There are probably others.