From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 37868 invoked by alias); 27 Aug 2015 15:31:14 -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 37854 invoked by uid 89); 27 Aug 2015 15:31:13 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qk0-f181.google.com Received: from mail-qk0-f181.google.com (HELO mail-qk0-f181.google.com) (209.85.220.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 27 Aug 2015 15:31:12 +0000 Received: by qkfh127 with SMTP id h127so12372566qkf.1 for ; Thu, 27 Aug 2015 08:31:10 -0700 (PDT) X-Received: by 10.55.198.9 with SMTP id b9mr7507172qkj.97.1440689470584; Thu, 27 Aug 2015 08:31:10 -0700 (PDT) Received: from [192.168.0.26] (97-122-175-227.hlrn.qwest.net. [97.122.175.227]) by smtp.gmail.com with ESMTPSA id 39sm1427862qkw.33.2015.08.27.08.31.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2015 08:31:09 -0700 (PDT) Message-ID: <55DF2D3C.8020208@gmail.com> Date: Thu, 27 Aug 2015 15:31:00 -0000 From: Martin Sebor User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Stephan Gatzka , gcc-help@gcc.gnu.org Subject: Re: parameter type of -frandom-seed References: <1440521295.3861.3.camel@gmail.com> <55DCFD7A.3090609@gmail.com> <1440653742.3277.11.camel@gmail.com> In-Reply-To: <1440653742.3277.11.camel@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-08/txt/msg00201.txt.bz2 On 08/26/2015 11:35 PM, Stephan Gatzka wrote: > Thanks for the answer. > >> but it looks like there's a bug in the option's specification that >> prevents invalid (non-numeric) arguments from being diagnosed, making >> GCC accept anything (including negative numbers). >> > > True, it accept strings and negative decimal numbers and hexadecimal > numbers and even gives me identical binaries... > > So you would say that the only valid parameter to -frandom-seed is an > unsigned decimal number? > > -frandom-seed=18464 // correct > -frandom-seed=a48cb9 //wrong > -frandom-seed=foobar //wrong That is what I said, yes. GCC 5 documents a numeric argument. Earlier versions of gcc document a string argument. This was changed in commit cf3579 without adjusting the option specification to reject non-numeric or negative arguments. The option argument is processed in the set_random_seed function in toplev.c. The function takes a string argument and calls strtoul on it to obtain the numeric random seed (strtoul is called with the base argument of zero letting it detect it from the prefix). When strtoul fails, set_random_seed calls crc32_string with the string argument. So the function is capable of processing both numeric and string arguments. I suppose the question is whether GCC should should be changed back to accept string arguments as originally implemented, or whether it should stay as is and the option specification changed to match the documentation. Either way, there are problems here that should be fixed. Martin