This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFC: PR c++/36159: C++ compiler should issue a warning with missing new operator
On Tue, Jan 27, 2009 at 6:33 PM, Ian Lance Taylor <iant@google.com> wrote:
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
>> 2009-01-22 H.J. Lu <hongjiu.lu@intel.com>
>>
>> PR c++/36159
>> * c.opt (Walignment-new): New.
>>
>> * c-opts.c (c_common_handle_option): Handle warn_alignment_new.
>> (c_common_post_options): Likewise.
>>
>> * config/i386/linux.h (MALLOC_ABI_ALIGNMENT): New.
>> * config/i386/linux64.h (MALLOC_ABI_ALIGNMENT): Likewise.
>>
>> gcc/cp/
>>
>> 2009-01-22 H.J. Lu <hongjiu.lu@intel.com>
>>
>> PR c++/36159
>> * init.c (build_new_1): Warn memory alignment returned by global
>> operator new on types whose alignments are > MALLOC_ABI_ALIGNMENT
>> if warn_alignment_new isn't zero.
>
>
> This new warning is OK in principle, but I think it is useless in
> practice, because MALLOC_ABI_ALIGNMENT is incorrect for essentially
> every target. The patch will cause -Walignment-new to warn about
> new(double) on many if not most platforms.
It is easy to write a testcase so that platform maintainer can verify
that correct MALLOC_ABI_ALIGNMENT.
> I think we should tackle this in 4.5, rather than try to shoehorn
> something into 4.4.
>
I will queue it for 4.5.
Thanks.
--
H.J.