From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14389 invoked by alias); 24 May 2012 18:38:56 -0000 Received: (qmail 14315 invoked by uid 22791); 24 May 2012 18:38:55 -0000 X-SWARE-Spam-Status: No, hits=-4.3 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00,KHOP_THREADED X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 May 2012 18:38:42 +0000 From: "dodji at seketeli dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/52952] Wformat location info is bad (wrong column number) Date: Thu, 24 May 2012 18:44:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: dodji at seketeli dot org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-05/txt/msg02409.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D52952 --- Comment #9 from dodji at seketeli dot org 2= 012-05-24 18:38:40 UTC --- "manu at gcc dot gnu.org" a =C3=A9crit: > So either one keeps track of all source locations of all "interesting" > characters within strings, which sounds infeasible. Or one needs to > re-preprocess the format string, creating new locations on-the-fly. Dodji= , is > this possible? With the current infrastructure, I fear we cannot re-process the format string *after* the initial pre-processing phase is done, to create new locations that we'd a in the line maps. However, briefly looking at the source code, we might be able to pull this whole shebang off, in a way. I am thinking that in gcc/c-family/c-format.c:check_format_info_main, we can arrange for the instance of format_kind_info (that is the result of parsing the format string) to carry the virtual location of the beginning of the format string *and* the offset of the relevant character we might want to warn about. Then, later the routines that trigger the warning by analyzing the instance= of format_kind_info could be passed the relevant location for the beginning of the of the format string as well as the byte offset of the relevant character I talked about above. At warning type, it could re-construct the exact column where of that relevant character, with its byte offset and the virtual location of the beginning of the format string. Does that make sense?