Exception: Segment Violation

  • Follow


Hi,

/*--main.c--[begin]--*/
#include <stddef.h> /* NULL */
#include <stdlib.h> /* EXIT_SUCCESS */
typedef struct
{
  struct {int value;} size;
  int count;
} mystruct_t;
int test(mystruct_t * ms)
{
  int result = 0;
  if (ms != NULL)
  {
    result = ms->count;
  }
  return result;
}
int main(void)
{
  test(NULL);
  return EXIT_SUCCESS;
}
/*--main.c--[end]--*/

> lcc -O -c main.c
> lcclnk -subsystem console main.obj -o main.exe
> main.exe
(program crash)

program crash ONLY with option -O or -unused.

> lcc -v
Logiciels/Informatique lcc-win32 version 3.8. Compilation date: Apr  6
2010 13:15:36

Regards

-- 
Maciek
0
Reply MaciekL 4/17/2010 9:17:32 AM

Thanks for your bug report

With optimizations ON, lcc would generate a conditional move
instruction (cmovne). Apparently, that instruction will access the memory
ANYWAY even if the condition is FALSE.

This is a big mistake from my part.

I fixed this. Thanks for your (very good) bug report.

jacob

0
Reply jacob 4/17/2010 4:58:13 PM


1 Replies
537 Views

(page loaded in 0.028 seconds)

Similiar Articles:













7/26/2012 6:15:22 PM


Reply: