Bug 1392 - warning on WIFEXITED(const int) et al: assignment of read-only member
Summary: warning on WIFEXITED(const int) et al: assignment of read-only member
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.3.3
: P2 normal
Target Milestone: ---
Assignee: GOTO Masanori
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-09-29 17:49 UTC by Martin Sebor
Modified: 2018-04-19 14:23 UTC (History)
1 user (show)

See Also:
Host: ppc-suse-linux
Target: ppc-suse-linux
Build: ppc-suse-linux
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Sebor 2005-09-29 17:49:55 UTC
$ cat t.c && gcc -c t.c
#include <sys/wait.h>

int foo ()
{
    const int status = 0;

    WIFEXITED (status);
    WEXITSTATUS (status);
    WIFSIGNALED (status);
    WTERMSIG (status);
    WIFSTOPPED (status);
    WSTOPSIG (status);
    WIFCONTINUED (status);
}
t.c: In function `foo':
t.c:7: warning: assignment of read-only member `__in'
t.c:8: warning: assignment of read-only member `__in'
t.c:9: warning: assignment of read-only member `__in'
t.c:10: warning: assignment of read-only member `__in'
t.c:11: warning: assignment of read-only member `__in'
t.c:12: warning: assignment of read-only member `__in'
Comment 1 Sourceware Commits 2005-09-29 20:44:51 UTC
Subject: Bug 1392

CVSROOT:	/cvs/glibc
Module name:	libc
Changes by:	roland@sources.redhat.com	2005-09-29 20:44:44

Modified files:
	posix/sys      : wait.h 

Log message:
	2005-09-29  Roland McGrath  <roland@redhat.com>
	
	[BZ #1392]
	* posix/sys/wait.h (__WAIT_INT): Rewrite using an initializer,
	in case __typeof yields a const-qualified type.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/posix/sys/wait.h.diff?cvsroot=glibc&r1=1.37&r2=1.38

Comment 2 Martin Sebor 2005-09-29 21:56:33 UTC
FWIW, looking at the patch, the definition of __WAIT_INT() looks like it might
generate a warning with -Wcast-qual. I suggest to change the cast to (const int*).

$ cat t.cpp && gcc -Wcast-qual t.cpp
#define __WAIT_INT(status)      (*(int *) &(status))

int main ()
{
    const int status = 0;
    return __WAIT_INT(status);
}
t.cpp: In function `int main()':
t.cpp:6: warning: cast from `const int*' to `int*' discards qualifiers from 
   pointer target type
Comment 3 Sourceware Commits 2005-09-29 22:03:21 UTC
Subject: Bug 1392

CVSROOT:	/cvs/glibc
Module name:	libc
Changes by:	roland@sources.redhat.com	2005-09-29 22:03:14

Modified files:
	posix/sys      : wait.h 

Log message:
	2005-09-29  Roland McGrath  <roland@redhat.com>
	
	[BZ #1392]
	* posix/sys/wait.h [!__GNUC__ || __cplusplus] (__WAIT_INT): Use const.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/libc/posix/sys/wait.h.diff?cvsroot=glibc&r1=1.38&r2=1.39

Comment 4 Ulrich Drepper 2005-10-14 06:14:48 UTC
Apparently the sources have been adjusted.