This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/27153] New: function result is dereferenced error


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]