From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46116 invoked by alias); 23 Nov 2019 14:16:13 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 46098 invoked by uid 89); 23 Nov 2019 14:16:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=1.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=jg@jguk.org, jgjgukorg, D*jguk.org, U*jg X-HELO: mail-wm1-f48.google.com Received: from mail-wm1-f48.google.com (HELO mail-wm1-f48.google.com) (209.85.128.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 23 Nov 2019 14:16:12 +0000 Received: by mail-wm1-f48.google.com with SMTP id b11so1051587wmj.4 for ; Sat, 23 Nov 2019 06:16:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iebJ2G5LUz2jF1Z4vtHWg2rKG18KVT7iGZHgorhJhM8=; b=rqX/kh7i4zVNYBw8kDE3VlIea9i0SgeKXg9pCzSk6kdjlkNknZepvMB+kLHlfQIqEz Q3yF3xAYwk3xw4dnRsPvIjjCvayJ84UUjSxcofVijHZktc0de5XhDfRr3zYWRQ0txQok UGJYQxTRFyR5CVH4UONN3fLA+AFpVoQxiPul0SSv94hRI6L8LvI2IqLGJ11EcnqS+vUl ofoV031Bt05G3fUjOqRvgTPuVGZSnVsPbjD7+urhS0vMHWqHi0n84wivZ3pXyGvz2uS1 ciEVOMhvzqYmF3/LdON3ajCIiqFLtQm20EgfC8VZPK0ICkmOnZbKuzwLGKL5GYGLzLpw uBZQ== MIME-Version: 1.0 References: <9e2a9f57-bdfc-3da3-110d-2f8d51f85b0e@jguk.org> In-Reply-To: <9e2a9f57-bdfc-3da3-110d-2f8d51f85b0e@jguk.org> From: Ponnuvel Palaniyappan Date: Sat, 23 Nov 2019 14:16:00 -0000 Message-ID: Subject: Re: shift-count-overflow possible issue on 64bit type To: Jonny Grant Cc: gcc-help Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2019-11/txt/msg00076.txt.bz2 The shift actually happens as int because the type of 1 is int, and the result is then assigned to size_t. You can instead use a wider type: size_t big =3D 1UL<<41; On Sat, 23 Nov 2019, 13:56 Jonny Grant, wrote: > I see on my 64bit Ubuntu PC that size_t is 8 bytes, that is 64bits, > however I see a warning: > > $ g++-8 -Wall -Wextra -o size_t size_t.cpp > size_t.cpp: In function =E2=80=98int main()=E2=80=99: > size_t.cpp:11:21: warning: left shift count >=3D width of type > [-Wshift-count-overflow] > size_t big =3D 1<<40; > ^~ > > > > Same on Godbolt trunk. > Is this an issue? > > Regards, Jonny > > https://godbolt.org/z/xeefQ8 > > #include > size_t big =3D 1<<41; > > > > Please keep my email on any replies > Jonny >