Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: marat at slonopotamus dot org
Target Milestone: ---
A test program:
int main()
{
int *a = new int[10]();
delete[] a;
return 0;
}
Tested against: gcc 10.2.0 and gcc trunk as
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97151
--- Comment #1 from Marat Radchenko ---
Another program that exhibits the same behavior:
int main()
{
int *a = new int[10];
a[0] = 0;
delete[] a;
return 0;
}
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97151
--- Comment #4 from Marat Radchenko ---
(In reply to Martin Liška from comment #3)
> It's caused by what was mentioned as 2) which transforms to:
>
> _6 = operator new [] (40);
> __builtin_memset (_6, 0, 40);
> operator delete [] (_6);
>
erity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: marat at slonopotamus dot org
Target Milestone: ---
Given the following code
#include
static const char* const a = "bla";
static const char b[] = &
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108626
--- Comment #2 from Marat Radchenko ---
Thanks for the pointer to -fmerge-all-constants, that helped me to google out
why such transformation is invalid: https://stackoverflow.com/a/70328102
Should I close this issue as INVALID (and probably op
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108626
--- Comment #5 from Marat Radchenko ---
So, does "String literals, and compound literals with const-qualified types,
need not designate distinct objects." apply here or not? If not, how does the
case where it applies look like?
https://en.cppre
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108626
--- Comment #7 from Marat Radchenko ---
While playing with it more, I found that clang behaves in a very strange way.
While they do combine `const char* const` + `const char[]`, the DO NOT combine
two `const char[]` together. I don't have any ex
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108626
--- Comment #8 from Marat Radchenko ---
Also, quote from C17 standard:
Like string literals, const-qualified compound literals can be placed into
read-only memory and *can even be shared*. (6.5.2.5 p 13).