This is the mail archive of the
mailing list for the GCC project.
Re: "error: static assertion failed: [...]" (was: [GCC Wiki] Update of "DiagnosticsGuidelines" by MartinSebor)
- From: Manuel López-Ibáñez <lopezibanez at gmail dot com>
- To: Thomas Schwinge <thomas at codesourcery dot com>, gcc at gcc dot gnu dot org
- Cc: Martin Sebor <msebor at gmail dot com>
- Date: Thu, 14 Jul 2016 03:46:32 +0100
- Subject: Re: "error: static assertion failed: [...]" (was: [GCC Wiki] Update of "DiagnosticsGuidelines" by MartinSebor)
- Authentication-results: sourceware.org; auth=none
- References: <firstname.lastname@example.org> <email@example.com>
On 13/07/16 14:26, Thomas Schwinge wrote:
I had recently noticed that given:
#ifndef __cplusplus /* C */
#else /* C++ */
..., for C we diagnose:
[...]:2:1: error: static assertion failed: "foo"
..., and for C++ we diagnost:
[...]:4:1: error: static assertion failed: foo
("foo" quoted vs. un-quoted.) Assuming this difference between C and C++
diagnostics is not intentional, which one should we settle on? I thought
I'd like the un-quoted version better, but judging by Martin's recent
wiki change (see below), "foo" is a string constant, so should be quoted
in diagnostics? If yes, OK to commit to trunk the obvious changes (plus
any testsuite updates)?
From a diagnostics point-of-view, neither version is quoted:
c/c-parser.c: error_at (assert_loc, "static assertion failed: %E", string);
cp/semantics.c: error ("static assertion failed: %s",
To be "quoted", it would need to use either %q or %<%>. Note that %qs would
produce `foo' not "foo". Nevertheless, we probably want to print 'x' for
character literals and not `'x'' and "string" for string literals and not
`string'. Thus, the wiki should probably be amended to clarify this.
Also, there is a substantial difference between %E and %s when the string
contains control characters such as \n \t \u etc. Clang uses something similar
For comparison, we use %s to print
test.c:1:9: note: #pragma message:
#pragma message "\nstring"