public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/106974] New: g++ bug caused by r260621
@ 2022-09-20 9:50 duan.db at linux dot alibaba.com
2022-09-20 10:41 ` [Bug c++/106974] " marxin at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: duan.db at linux dot alibaba.com @ 2022-09-20 9:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106974
Bug ID: 106974
Summary: g++ bug caused by r260621
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: duan.db at linux dot alibaba.com
Target Milestone: ---
hi, I found a g++ bug.
code is shown as below:
https://godbolt.org/z/5Ex564eGE
It works fine on GCC 8, but will Segmentation fault on GCC9, GCC10...
By using bisect, I found the commit which causing this problem.
https://gcc.gnu.org/git/?p=gcc.git&a=commit;h=955da5e5443724cb59f8fbd854c13e78c68bf000
But I'm not familiar with this part of GCC, hope to get your help, thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/106974] g++ bug caused by r260621
2022-09-20 9:50 [Bug c++/106974] New: g++ bug caused by r260621 duan.db at linux dot alibaba.com
@ 2022-09-20 10:41 ` marxin at gcc dot gnu.org
2022-09-20 10:45 ` [Bug c++/106974] g++ bug caused by r9-595-g955da5e5443724cb marxin at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-09-20 10:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106974
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Thanks for the repo, next time, please attach source code directly here w/o any
external service.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/106974] g++ bug caused by r9-595-g955da5e5443724cb
2022-09-20 9:50 [Bug c++/106974] New: g++ bug caused by r260621 duan.db at linux dot alibaba.com
2022-09-20 10:41 ` [Bug c++/106974] " marxin at gcc dot gnu.org
@ 2022-09-20 10:45 ` marxin at gcc dot gnu.org
2022-09-20 11:04 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-09-20 10:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106974
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Summary|g++ bug caused by r260621 |g++ bug caused by
| |r9-595-g955da5e5443724cb
Last reconfirmed| |2022-09-20
Ever confirmed|0 |1
CC| |jason at gcc dot gnu.org
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
$ g++ pr106974.C -fsanitize=undefined && ./a.out
pr106974.C: In instantiation of ‘const NumType&
TestVector<NumType>::operator[](int) const [with NumType = unsigned int]’:
pr106974.C:24:24: required from here
pr106974.C:16:34: warning: returning reference to temporary
[-Wreturn-local-addr]
16 | return shard_index_[0].data[0];
| ~~~~~~~~~~~~~~~~~~~~^
pr106974.C:16:36: runtime error: reference binding to null pointer of type
'const unsigned int'
pr106974.C:24:11: runtime error: load of null pointer of type 'const unsigned
int'
Segmentation fault (core dumped)
while clang is fine:
$ clang++ pr106974.C -fsanitize=undefined && ./a.out
0
Really started with r9-595-g955da5e5443724cb.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/106974] g++ bug caused by r9-595-g955da5e5443724cb
2022-09-20 9:50 [Bug c++/106974] New: g++ bug caused by r260621 duan.db at linux dot alibaba.com
2022-09-20 10:41 ` [Bug c++/106974] " marxin at gcc dot gnu.org
2022-09-20 10:45 ` [Bug c++/106974] g++ bug caused by r9-595-g955da5e5443724cb marxin at gcc dot gnu.org
@ 2022-09-20 11:04 ` pinskia at gcc dot gnu.org
2022-09-20 11:04 ` marxin at gcc dot gnu.org
2022-09-20 15:20 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-09-20 11:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106974
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I think gcc is correct here. You cannot take the address of an element of a
packed structure.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/106974] g++ bug caused by r9-595-g955da5e5443724cb
2022-09-20 9:50 [Bug c++/106974] New: g++ bug caused by r260621 duan.db at linux dot alibaba.com
` (2 preceding siblings ...)
2022-09-20 11:04 ` pinskia at gcc dot gnu.org
@ 2022-09-20 11:04 ` marxin at gcc dot gnu.org
2022-09-20 15:20 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-09-20 11:04 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106974
--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
Code:
#include <vector>
#include <cstdio>
template <typename NumType>
struct __attribute__ ((__packed__)) Shard {
NumType data[128];
};
template<typename NumType>
class TestVector {
public:
TestVector() {
shard_index_.push_back(Shard<NumType>());
}
const NumType& operator[](int i) const {
return shard_index_[0].data[0];
}
private:
std::vector<Shard<NumType>> shard_index_;
};
int main(){
TestVector<unsigned int> vec;
printf("%u\n",vec[0]);
return 0;
}
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c++/106974] g++ bug caused by r9-595-g955da5e5443724cb
2022-09-20 9:50 [Bug c++/106974] New: g++ bug caused by r260621 duan.db at linux dot alibaba.com
` (3 preceding siblings ...)
2022-09-20 11:04 ` marxin at gcc dot gnu.org
@ 2022-09-20 15:20 ` pinskia at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-09-20 15:20 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106974
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://gcc.gnu.org/legacy-ml/gcc-patches/2003-07/msg01664.html
This was an expected change really with that patch.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-09-20 15:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-20 9:50 [Bug c++/106974] New: g++ bug caused by r260621 duan.db at linux dot alibaba.com
2022-09-20 10:41 ` [Bug c++/106974] " marxin at gcc dot gnu.org
2022-09-20 10:45 ` [Bug c++/106974] g++ bug caused by r9-595-g955da5e5443724cb marxin at gcc dot gnu.org
2022-09-20 11:04 ` pinskia at gcc dot gnu.org
2022-09-20 11:04 ` marxin at gcc dot gnu.org
2022-09-20 15:20 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).