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/44939] New: Questions on details of -pedantic


Why does it change the output of the compilation of certain programs? The
documentation implies strongly that it only affects the warnings produced. The
following program demonstrates this.

-----
/* Authors: Florian Schanda and Martin Brain */
#include <stdio.h>

int main(int argc, char ** argv)
{
  const int foo = 5;
  int b;
  void * ptr;
  int * intptr;

  ptr = (void*)&foo;
  intptr  = (int*)ptr;

  *intptr = 10;
  b = foo;

  if (b == 5) {
    printf("You seem to constant fold stuff.\n");
  } else {
    printf("You don't seem to constant fold.\n");
  }

  return 0;
}
-----

$ gcc -Wall -O3 stupid.c && ./a.out
You seem to constant fold stuff.

$ gcc -Wall -O3 -pedantic stupid.c && ./a.out
You don't seem to constant fold.

We note that this "works" as expected with g++, i.e. pedantic doesn't change
the output of the program.


-- 
           Summary: Questions on details of -pedantic
           Product: gcc
           Version: 4.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: florian at schanda dot org dot uk


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44939


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