public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/49585] New: need a warning about new/malloc returning unsufficiently aligned memory
@ 2011-06-30 4:47 sergey.v.maslov at intel dot com
2011-06-30 4:51 ` [Bug c++/49585] " hjl.tools at gmail dot com
0 siblings, 1 reply; 2+ messages in thread
From: sergey.v.maslov at intel dot com @ 2011-06-30 4:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49585
Summary: need a warning about new/malloc returning
unsufficiently aligned memory
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: sergey.v.maslov@intel.com
Consider the following test case:
#define alignement 64
struct test {
public:
int toto[100] __attribute__((aligned(alignement)));
};
int main () {
test* t = new test();
printf("%ld\n",(unsigned long)(&(t->toto[0])) % alignement);
return 0;
}
This program typically prints a non-zero value, whereas customers would
actually expect 0. This is due to default "new" (presumably doing malloc) only
gurantees 16 byte alignment.
Compiler should detect when a default new operator is used to allocate
unsufficiently aligned memory, and issue a relevent user diagnostics.
BTW, this issues can cause severe stability problems in AVX compilation, where
32-byte is the typical requirement for 256-bit AVX data types.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/49585] need a warning about new/malloc returning unsufficiently aligned memory
2011-06-30 4:47 [Bug c++/49585] New: need a warning about new/malloc returning unsufficiently aligned memory sergey.v.maslov at intel dot com
@ 2011-06-30 4:51 ` hjl.tools at gmail dot com
0 siblings, 0 replies; 2+ messages in thread
From: hjl.tools at gmail dot com @ 2011-06-30 4:51 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49585
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Version|unknown |4.7.0
Resolution| |DUPLICATE
--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> 2011-06-30 04:50:54 UTC ---
Dup.
*** This bug has been marked as a duplicate of bug 36159 ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-06-30 4:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-30 4:47 [Bug c++/49585] New: need a warning about new/malloc returning unsufficiently aligned memory sergey.v.maslov at intel dot com
2011-06-30 4:51 ` [Bug c++/49585] " hjl.tools at gmail dot com
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).