From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id B34283858D1E for ; Thu, 10 Nov 2022 19:16:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B34283858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668107796; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=A5VqZ2XSEUvI8xLR4CEtIUg9FfzorwlJyK8ZnOP5Xhs=; b=HZutL38fTXvAOHwPr5nbjaW6mer8kyLF7O9cy5E7IR21qwWfUKPH3DuqwD9cxgZIJmnl+2 Tx8FqS102GJm2VwT1jVaCYO8swOmiPW3+tXQSWjCoB2XFLBpTxle23n2LIA57t/JCV3ii5 LL+j/w2POLl7DFvdQr5zHQtqBgyQ3Fg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-126-aPJQVmRNP8y9yVHtDzGqkw-1; Thu, 10 Nov 2022 14:16:33 -0500 X-MC-Unique: aPJQVmRNP8y9yVHtDzGqkw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 79F3E800B30 for ; Thu, 10 Nov 2022 19:16:33 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.193.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F410C15BA8; Thu, 10 Nov 2022 19:16:32 +0000 (UTC) From: Florian Weimer To: Marek Polacek Cc: gcc@gcc.gnu.org Subject: Re: -Wint-conversion, -Wincompatible-pointer-types, -Wpointer-sign: Are they hiding constraint C violations? References: <87mt8ysm3y.fsf@oldenburg.str.redhat.com> Date: Thu, 10 Nov 2022 20:16:30 +0100 In-Reply-To: (Marek Polacek's message of "Thu, 10 Nov 2022 13:43:22 -0500") Message-ID: <87h6z6sjqp.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Marek Polacek: > On Thu, Nov 10, 2022 at 07:25:21PM +0100, Florian Weimer via Gcc wrote: >> GCC accepts various conversions between pointers and ints and different >> types of pointers by default, issuing a warning. >> >> I've been reading the (hopefully) relevant partso f the C99 standard, >> and it seems to me that C implementations are actually required to >> diagnose errors in these cases because they are constraint violations: >> the types are not compatible. > > It doesn't need to be a hard error, a warning is a diagnostic message, > which is enough to diagnose a violation of any syntax rule or > constraint. > > IIRC, the only case where the compiler _must_ emit a hard error is for > #error. Hmm, you could be right. The standard says that constraint violations are not undefiend behavior, but of course it does not define what happens in the presence of a constraint violation. So the behavior is undefined by omission. This seems to be a contradiction. I assumed that there was a rule similar to the the rule for #error for any kind of diagnostic, which would mean that GCC errors are diagnostic messages in the sense of the standard, but GCC warnings are not. I wonder how C++ handles this. Thanks, Florian