[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#474086: marked as done (gcc-4.2: Constant optimization for strlen() prints bogus warnings)



Your message dated Tue, 23 Jun 2015 07:24:48 +0000
with message-id <E1Z7IZc-0001tY-Ii@franck.debian.org>
and subject line Bug#789156: Removed package(s) from unstable
has caused the Debian Bug report #474086,
regarding gcc-4.2: Constant optimization for strlen() prints bogus warnings
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
474086: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=474086
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Reportbug-Version: 3.39
X-Debbugs-Cc: philipp.marek@bmlv.gv.at
Package: gcc-4.2
Version: 4.2.3-3
Severity: minor


I try to compile the attached C file via the command 
	$ gcc -Wall -Os -S %

and get several warnings:
	test.c:6: warning: initializer element is not constant
	test.c:6: warning: (near initialization for ‘i’)
	test.c:7: warning: initializer element is not constant
	test.c:7: warning: (near initialization for ‘si’)
	test.c:8: warning: initializer element is not constant
	test.c:8: warning: (near initialization for ‘ci’)
	test.c:11: warning: initializer element is not constant
	test.c:11: warning: (near initialization for ‘s’)

Now all of the strlen() calls get (correctly!) optimized out into 
constants; but why do I get the warnings?

I know that constants used within functions could be done via atstart() 
mechanism or on first function call; but as these lengths are already 
constants in the assembler output, any strlen() overloading wouldn't 
work anyway.


So, as conclusion:
If strlen() is taken as known for constant strings (and optimized 
as such), no warning about its return value being non-constant 
should be given.


Or am I missing some part of the picture?


-- System Information:
Debian Release: lenny/sid
  APT prefers testing
  APT policy: (600, 'testing'), (50, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.22-1-686 (SMP w/1 CPU core)
Locale: LANG=de_AT.UTF-8, LC_CTYPE=de_AT.UTF-8 (charmap=UTF-8) (ignored: LC_ALL set to de_AT.utf8)
Shell: /bin/sh linked to /bin/bash

Versions of packages gcc-4.2 depends on:
ii  binutils            2.18.1~cvs20080103-3 The GNU assembler, linker and bina
ii  cpp-4.2             4.2.3-3              The GNU C preprocessor
ii  gcc-4.2-base        4.2.3-3              The GNU Compiler Collection (base 
ii  libc6               2.7-10               GNU C Library: Shared libraries
ii  libgcc1             1:4.3.0-3            GCC support library

Versions of packages gcc-4.2 recommends:
ii  libc6-dev                     2.7-10     GNU C Library: Development Librari

-- no debconf information

Attachment: test.s
Description: Binary data

#include <string.h>
#include <stdio.h>

#define STG "asdf"

int i=strlen(STG);
static int si=strlen(STG);
const int ci=strlen(STG);

struct { int i; } 
s={ .i=strlen(STG) };

int main(void)
{
	int l=strlen(STG);
	const int cl=strlen(STG);

	printf("local %d, const local %d; global %d, static %d, const %d, struc %d\n", 
			l, cl,
			i, si,ci,
			s.i);

	return 0;
}

--- End Message ---
--- Begin Message ---
Version: 4.7.4-3+rm

Dear submitter,

as the package gcc-4.7 has just been removed from the Debian archive
unstable we hereby close the associated bug reports.  We are sorry
that we couldn't deal with your issue properly.

For details on the removal, please see https://bugs.debian.org/789156

The version of this package that was in Debian prior to this removal
can still be found using http://snapshot.debian.org/.

This message was generated automatically; if you believe that there is
a problem with it please contact the archive administrators by mailing
ftpmaster@ftp-master.debian.org.

Debian distribution maintenance software
pp.
Luca Falavigna (the ftpmaster behind the curtain)

--- End Message ---

Reply to: