From owner-freebsd-hackers@freebsd.org Wed Feb 26 19:58:59 2020 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4C19724306C for ; Wed, 26 Feb 2020 19:58:59 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound3d.ore.mailhop.org (outbound3d.ore.mailhop.org [54.186.57.195]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 48SRSy3XB3z3R6X for ; Wed, 26 Feb 2020 19:58:58 +0000 (UTC) (envelope-from ian@freebsd.org) ARC-Seal: i=1; a=rsa-sha256; t=1582747135; cv=none; d=outbound.mailhop.org; s=arc-outbound20181012; b=qnEwzmBQ2db0IxzQLGdMTnQ/QD1YxA2CA0F6+t6zLubYdMyVg1YKzxT2qa54265CoReQV7BJkKDCC dGz5BCWNTc+1vICRv4V1PJ7rkBea46r9zwAWc8GlUJKkktoHP20TiiOmLrdlzCYEaxmkndlz7xQQCZ yHqAPDk2HnfMpPbkNQuNnG39gPHqqtawihkUXsLKoh6p5lXfacxvA/Ni9IM06yvN9DyaSq+k1xWDyr ilb7BNHBlXDMmFuXG9XCPVQ/e3cZeJg+FuXkanmbMH0+Q3OxrDJVlXQvEgfdb6/uaNR73yYYqq9o3N +Yu0GBG2OxyS3u6Wa6iTRl1BBysHw8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=arc-outbound20181012; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:dkim-signature:from; bh=1JLm+WGNXb2WHlUlic0mAZ8QASnt2g6K/lprhrIt7gE=; b=p6U/coyU13dsLDMVN8F7tMMSjCX6y9CAKoJTk2ZXBBQDG7wigBO/x+M49QipZt6HC1eD5PjXlfUaY K2Nkfq1vuQEs9Niny1+OxzAUbbOJAXqIF4bvR9zoD4dMCfz5LGFeDblanadN9lSiUv+fw4AJIURgwr 0btEZXu2M/1FJJ4dbUp/vriX5K8BakYoGsUL9mGUo8xGibKl8RFiTifEB1GeYpFMTuF6WLiJoVMRlv aXCJms30otr/9LEC2zwWRDGNQthVBcAiEVLN3j+Q/vKy3yyzZPPDgOToVawOh8pGOgG4UV5Mrq2GTG hwZBn4eyIW/ukaBcWuTFhyxQb6NmCiQ== ARC-Authentication-Results: i=1; outbound3.ore.mailhop.org; spf=softfail smtp.mailfrom=freebsd.org smtp.remote-ip=67.177.211.60; dmarc=none header.from=freebsd.org; arc=none header.oldest-pass=0; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outbound.mailhop.org; s=dkim-high; h=content-transfer-encoding:mime-version:content-type:references:in-reply-to: date:to:from:subject:message-id:from; bh=1JLm+WGNXb2WHlUlic0mAZ8QASnt2g6K/lprhrIt7gE=; b=rtzHX3T3QSyZQvpNpnGw6/xJvY1jaBKOTDHsPfpxYP92PCsUVlWyCf61Zj3lqaGmSjc130xUwqt/D TuQ/e1G2mPwLTEPdnOt75R94un1QvMr5z/g73PuW9qacoDPHyXOwFWutP37EHJuCLr+xnCrvsPoAtm W/K2NcRxnGKKmt3LVPu18HfJ7xp6IKWcUnqT5eqo0UzyYhMJaIceffz1UzEWPhv+K8WxRlv94n8XGe 535AJ3LbTmYayoy0g5zUQrsLzupqIXfjqT0rSKxbHrgsAwUoPO6ggUlUTEPyIS/I+C+XHuEoe5Tm0k NjFz7NgKnvGJHdBR0BJUVi4biaS2jrA== X-MHO-RoutePath: aGlwcGll X-MHO-User: 68fde73e-58d2-11ea-b80e-052b4a66b6b2 X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 67.177.211.60 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [67.177.211.60]) by outbound3.ore.mailhop.org (Halon) with ESMTPSA id 68fde73e-58d2-11ea-b80e-052b4a66b6b2; Wed, 26 Feb 2020 19:58:54 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id 01QJwpuR031365; Wed, 26 Feb 2020 12:58:51 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <6eae8193e54b29320b63d4f1a3442a0c455fa12b.camel@freebsd.org> Subject: Re: FreeBSD raspberry pi C compiler strangeness From: Ian Lepore To: Wojciech Puchar , freebsd-hackers@freebsd.org Date: Wed, 26 Feb 2020 12:58:51 -0700 In-Reply-To: References: Content-Type: text/plain; charset="ASCII" X-Mailer: Evolution 3.28.5 FreeBSD GNOME Team Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 48SRSy3XB3z3R6X X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-1.95 / 15.00]; local_wl_from(0.00)[freebsd.org]; NEURAL_HAM_MEDIUM(-0.95)[-0.954,0]; ASN(0.00)[asn:16509, ipnet:54.186.0.0/15, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Feb 2020 19:58:59 -0000 On Wed, 2020-02-26 at 20:45 +0100, Wojciech Puchar wrote: > i wrote my program and tested completely my program on x64 laptop > under > FreeBSD 11 > > then i compiled this program under FreeBSD on raspberry pi (quite > latest > version downloaded less than 2 months ago). > > And program didn't work properly. > > Finally i found a problem. > > char is signed by default on x64. > > On raspberry pi char is unsigned by default. > replacing "char" with "signed char" fixed problem completely. > > Why char is unsigned on FreeBSD/raspberry pi? > The C standard allows plain char types to be signed or unsigned by default. Char has always been unsigned by default on arm platforms (not just freebsd, it's mandated by the ARM ABI document). Usually when you run into trouble with this, it's a sign that your code should be using int8_t, not char. If the trouble arises with something like calling getc(3) and testing for EOF, the problem is that getc() returns an int, not a char, so you need to assign the return value to an int for testing against EOF. -- Ian