This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH,c++] use XALLOCAVEC in the C++ front-end


On 06/06/2010 08:52 PM, Nathan Froyd wrote:
Just a minor cleanup noticed while browsing around.

There's still one call that seems like it ought to be replaceable: in
semantics.c:finish_asm_stmt, we have:

oconstraints = (const char **) alloca (noutputs * sizeof (char *));

But changing this to:

oconstraints = (const char **) XALLOCAVEC (char *, noutputs);

gives the error:

semantics.c: In function âfinish_asm_stmtâ:
semantics.c:1223:7: error: new âconstâ qualifier in middle of multi-level non-const cast is unsafe [-Werror=cast-qual]

which I don't understand, because the cast is not in the "middle" of
anything.  Is this a bug in the cast checking?

The error message is unclear, but the issue is that converting from char** to char const** is unsafe, while converting to char const*const* is safe.


Just use XALLOCAVEC(const char *, noutputs) with no extra cast.

Jason


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]