This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: stray quotation marks warning enhancement or extension
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Daniel Gutson <daniel dot gutson at tallertechnologies dot com>
- Cc: gcc Mailing List <gcc at gcc dot gnu dot org>
- Date: Thu, 31 Mar 2016 23:23:02 +0100
- Subject: Re: stray quotation marks warning enhancement or extension
- Authentication-results: sourceware.org; auth=none
- References: <CAF5HaEVky8mR8=kyhgfpVMpi=bhrSZvKMd3jMUL99sd81yEg7g at mail dot gmail dot com>
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â ");