From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10416 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: syslog.h prioritynames define not compatible with -Wwrite-strings Date: Tue, 30 Aug 2016 17:20:02 -0400 Message-ID: <20160830212002.GM15995@brightrain.aerifal.cx> References: Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1472592030 25200 195.159.176.226 (30 Aug 2016 21:20:30 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 30 Aug 2016 21:20:30 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) Cc: musl@lists.openwall.com To: Per Johansson Original-X-From: musl-return-10429-gllmg-musl=m.gmane.org@lists.openwall.com Tue Aug 30 23:20:22 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1beqS8-0005Hl-Pp for gllmg-musl@m.gmane.org; Tue, 30 Aug 2016 23:20:16 +0200 Original-Received: (qmail 13786 invoked by uid 550); 30 Aug 2016 21:20:16 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 13768 invoked from network); 30 Aug 2016 21:20:15 -0000 Content-Disposition: inline In-Reply-To: Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:10416 Archived-At: On Thu, Aug 25, 2016 at 09:47:06AM +0200, Per Johansson wrote: > Hello, > > I'm trying to port a code base to musl. I've run into an issue with > prioritynames as defined by syslog.h: > > CODE *pri_code = prioritynames; > > produces > > error: initialization discards 'const' qualifier from pointer target > type [-Werror=discarded-qualifiers] > > This is repeated once per element in the array. > > While the error message points to -Wdiscarded-qualifiers I believe > this is actually due to us using -Wwrite-strings which turns string > literals into type const char* instead of char*. This is a nasty problem with how -Wwrite-strings is implemented. It does not act as a warning option but fundamentally changes the languages semantics in a way that is not C. I have an open bug report against gcc for this: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61579 > I suppose the most compatible solution would be to cast each string > literal to char* in the define. It's either that or use const char* in > the struct, but that's likely to cause issues in other programs. > Or use some trickery to disable the warning I suppose, wouldn't know about that. > > Please CC me on any reply as I'm currently not subscribed. > > Minimal code to reproduce: > > #define SYSLOG_NAMES > #include > CODE *c = prioritynames; > > Compiles without warning: > gcc -nostdinc -isystem include -isystem obj/include -c test.c > > Adding -Wwrite-strings give warnings: > gcc -Wwrite-strings -nostdinc -isystem include -isystem obj/include -c test.c Based on the above, I don't consider this a bug in musl but a bug in gcc's -Wwrite-strings. However, there are a lot of other problems created by the current implementation of the SYSLOG_NAMES stuff, and it needs to be redone entirely, probably more closely matching how legacy implementations did it (the SYSLOG_NAMES stuff is all legacy cruft anyway and shouldn't be used in modern code). Rich