This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/44939] New: Questions on details of -pedantic
- From: "florian at schanda dot org dot uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Jul 2010 22:25:32 -0000
- Subject: [Bug c/44939] New: Questions on details of -pedantic
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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