This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/27153] New: function result is dereferenced error
- From: "alexey at cs dot sunysb dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Apr 2006 02:28:20 -0000
- Subject: [Bug c/27153] New: function result is dereferenced error
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
An error occurs when a function result is dereferenced if used as another
function's argument:
void *func(int num) {
static int val;
val=num;
return (void*)&val;
}
int main() {
printf("%d %d %d\n", *((int*)func(1)), *((int*)func(2)), *((int*)func(3)));
return 0;
}
Output is "1 1 1" instead of "1 2 3". Compiled using "gcc test.c -o test".
--
Summary: function result is dereferenced error
Product: gcc
Version: 3.4.6
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: alexey at cs dot sunysb dot edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27153