RFC: PR c++/36159: C++ compiler should issue a warning with missing new operator

H.J. Lu hjl.tools@gmail.com
Wed Jan 21 20:47:00 GMT 2009


On Wed, Jan 21, 2009 at 12:28 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
>>>>
>>>> Any comments?
>>>
>>> As this is a perfectly valid program you cannot issue an error here.  If you are
>>
>> Yes, it is valid C++ program. But it won't work as user intended. I can
>> change it to warning.
>>
>>> clever enough to detect the problem, why not emit a call to posix_memalign
>>> and do the construction in-place instead?
>>
>> What you are suggesting is an extension to operator new with
>> alignment requirement. I was told that idea was rejected by C++
>> standard.  I don't think gcc should generate a different operator
>> new behind the back of programmer. Besides, such codes
>> aren't portable.
>
> How do you detect if the programmer has provided its own implementation
> of new that provides the necessary alignment?
>

It can be controlled by switches to make it

1. Silent.
2. Issue an error
3. Issue a warning.

Default can be any of above.

-- 
H.J.



More information about the Gcc-patches mailing list