[Bug c++/99362] New: invalid unused result

2021-03-03 Thread gcc at cookiesoft dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99362

Bug ID: 99362
   Summary: invalid unused result
   Product: gcc
   Version: 10.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc at cookiesoft dot de
  Target Milestone: ---
Target: arm

The following code will emit a warning on arm 32 bit compilers:

```
struct S {
[[nodiscard]] S() {}
};

int main() {
S s;
}
```

```
: In function 'int main()':
:6:7: warning: ignoring return value of 'S::S()', declared with
attribute 'nodiscard' [-Wunused-result]
6 | S s;
  |   ^
:2:19: note: declared here
2 | [[nodiscard]] S() {}
  |   ^
:6:7: warning: ignoring return value of 'S::S()', declared with
attribute 'nodiscard' [-Wunused-result]
6 | S s;
  |   ^
:2:19: note: declared here
2 | [[nodiscard]] S() {}
  |   ^
Compiler returned: 0
```

```
S s = {}
```

does not emit such warning.

Does not emit a warning on x86 compiler though.
Does not emit a warning on 9.x branch, seems to be a regression.

Godbolt link: https://godbolt.org/z/4Kof1x

[Bug c++/99362] invalid unused result

2021-03-03 Thread gcc at cookiesoft dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99362

--- Comment #2 from gcc at cookiesoft dot de ---
it's not my code, but a MCVE ;)

I'm using
[tomlplusplus](https://github.com/marzer/tomlplusplus/blob/master/toml.hpp) and
there the constructor is marked as nodiscard.

I may file an issue there.

So, what about this issue? I guess it's still a bug?!

[Bug c/99810] New: Wrong const evaluation of 64-bit division

2021-03-29 Thread gcc at cookiesoft dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99810

Bug ID: 99810
   Summary: Wrong const evaluation of 64-bit division
   Product: gcc
   Version: 10.2.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c
  Assignee: unassigned at gcc dot gnu.org
  Reporter: gcc at cookiesoft dot de
  Target Milestone: ---
  Host: x86_64
Target: arm

The following code produces a different result on arm and x86_64:

https://gcc.godbolt.org/z/PPvoscdWa
```
#include 
#include 

int main() {
printf("%" PRId64 "\n", -621357696 / 100);
}
```

ARM: -2006227456  (  886B 6600)
X86: -62135769600 ( FFF1 886B 6600)

No single warning is given and I of course would like to see the x86 output,
because that's the right one ;)

[Bug c/99810] Wrong const evaluation of 64-bit division

2021-03-29 Thread gcc at cookiesoft dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99810

--- Comment #3 from gcc at cookiesoft dot de ---
I actually haven't, but yes, you're right that it will print out the correct
value.
I'm somewhat sorry for the noise.

Is there a reason, e.g. performance, that the .word is "wrong"?

[Bug c/99810] Wrong const evaluation of 64-bit division

2021-03-29 Thread gcc at cookiesoft dot de via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99810

--- Comment #5 from gcc at cookiesoft dot de ---
Alright. Then again, sorry for the noise. I was hunting down a bug and thought
I found it with this one... so I have to search further.

Thank you everyone!