This is the mail archive of the gcc@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: stray quotation marks warning enhancement or extension


On 31 March 2016 at 21:10, Daniel Gutson wrote:
> Hi,
>
>   many times we copy code snippets from sources that change the
> Unicode quotation marks ( â â ) rather than " ". For example
>
>          const std::string a_string(âHelloâ);
>
> That line looks innocent but causes gcc to say
>
> xxxxx.cpp:4:1: error: stray â\342â in program
>  const std::string a_string(âHelloâ);
>  ^
>
> misleading the poor programmer with such error message and wrong
> column. A quick Google search says there are 171,000 matches for "
> error: stray â\342â in program" which may show that this is a very
> common issue.

I have hit that problem several times and would welcome a smarter diagnostic.


> I want to know if there is consensus to one of these solutions that I
> can implement:
>
>    * improve the error message for the case of the Unicode quotes such
> as adding "(seems Unicode quotes where used)"

IMHO this would be better.

It doesn't actually help fix the code, it only helps identify the
problem, but this is usually only a problem for small pieces of code
copied from a webpage, so fixing it isn't a huge task.

>    * add a flag for a GNU extension so Unicode quotes are treated as
> regular quotes

That could change the meaning of valid code unless it was careful to
ignore fancy quotes inside string literals,  e.g. we wouldn't want to
change the meaning of:

const std::string a_string(" âHelloâ ");


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