From owner-freebsd-toolchain@freebsd.org Sat Feb 20 12:51:21 2016 Return-Path: Delivered-To: freebsd-toolchain@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BA472AAE4D3 for ; Sat, 20 Feb 2016 12:51:21 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from theravensnest.org (theraven.freebsd.your.org [216.14.102.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "cloud.theravensnest.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 77F5CE8F for ; Sat, 20 Feb 2016 12:51:20 +0000 (UTC) (envelope-from theraven@FreeBSD.org) Received: from [192.168.0.7] (cpc91230-cmbg18-2-0-cust661.5-4.cable.virginm.net [82.1.230.150]) (authenticated bits=0) by theravensnest.org (8.15.2/8.15.2) with ESMTPSA id u1KCp8H3082712 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 20 Feb 2016 12:51:13 GMT (envelope-from theraven@FreeBSD.org) X-Authentication-Warning: theravensnest.org: Host cpc91230-cmbg18-2-0-cust661.5-4.cable.virginm.net [82.1.230.150] claimed to be [192.168.0.7] Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: confusing messages from clang From: David Chisnall In-Reply-To: <20160220005749.GA84382@troutmask.apl.washington.edu> Date: Sat, 20 Feb 2016 12:51:03 +0000 Cc: freebsd-toolchain@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: References: <20160220005749.GA84382@troutmask.apl.washington.edu> To: Steve Kargl X-Mailer: Apple Mail (2.2104) X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 20 Feb 2016 12:51:21 -0000 C compilers are always doing best effort attempts to report when you = feed them code that is not valid C. For example, in this case: On 20 Feb 2016, at 00:57, Steve Kargl = wrote: > if (i > 0) > goto corrupt; This is valid, as long as you have a label called corrupt to look for. = You do not, however, because: > return; >=20 > whoops: > printf("whoops\n"); > return >=20 > corrupt: > printf("corrupt\n=E2=80=9D); The statement: > return corrupt: printf("corrupt\n"); is just confusing. It appears to be trying to return the value in = corrupt (which is not an identifier that corresponds to any valid = variable) and then has some trailing characters after the end of the = statement. Fortunately, the compiler tells you exactly what is wrong: First it says: > foo.c:21:1: error: use of undeclared identifier 'corrupt'; did you = mean 'crypt'? > corrupt: > ^~~~~~~ Here, it is telling you that the value passed to your return statement = is an undeclared identifier. Then it tells you that you have more = tokens after the end of your return statement: > foo.c:21:8: error: expected ';' after return statement > corrupt: > ^ > ; I am slightly surprised that there=E2=80=99s no warning that a return = statement with a value is invalid in a function that returns void, but = perhaps that=E2=80=99s because after finding two things wrong with one = statement it gives up. The correct fix, of course, is to insert the missing semicolon after the = return at the end of line 19. If you had tried compiling the same thing = with gcc 5, then you would have noticed that you get very similar error = messages (though gcc doesn=E2=80=99t attempt to provide a fixit hint and = does warn that you have a return statement returning a value from a = function that returns void). David