This is the mail archive of the gcc-patches@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]

Re: PATCH RFA: -Wc++-compat warning about ++/-- with enum value


On Thu, May 14, 2009 at 11:24:49AM -0700, Ian Lance Taylor wrote:
> Steve Kargl <sgk@troutmask.apl.washington.edu> writes:
> 
> > Thanks for the explanation.  Unfortunately, I disagree with 
> > your assertation that I don't need to learn C++ as you move
> > forward.  From codingconventions.html,
> >
> >    Avoid the use of identifiers or idioms that would prevent code
> >    compiling with a C++ compiler.
> >
> > How do I recognize these identifiers and idioms with no knowledge
> > of C++?
> 
> 1) Learning the common subset of C and C++ does not require learning
>    C++.  It requires learning to identify code which is valid C but is
>    not valid C++.  The latter is a much smaller set than the former.
> 
> 2) You can rely on the -Wc++-compat option.  You don't need to care
>    about anything which it doesn't warn about.

Sure, -Wc++-compat prevents someone from committing code that,
for example, uses ++ on an enum-specifer entity.  That someone,
now needs to find a C++ reference that explains the issue and
how to code around the problem.

> > More to the point, including -Wc++-compat in CFLAGS can make it
> > impossible to do a binary search to determine what revision 
> > caused a regression.  Try backing out only the Fortran portion of
> > r146855 and rebuild. 
> 
> I don't understand how this is different from any other compiler
> warning.  Warnings do change over time.  For example, the same thing
> could have occurred when we toughened up -Wparentheses.
> 
> Note that -Wc++-compat has been in CFLAGS since at least gcc 4.2, so
> what is new is not -Wc++-compat, but the fact that -Wc++-compat is
> getting tougher.

Here's the problem.  There was a regression in fortran io,
and one recent change that touched trans-io.c was r146855.
It was found that r146855 was the cause, but one can't 
determine this from reverting the change to trans-io.c.

Script started on Thu May 14 11:34:01 2009
REMOVE:kargl[201] cd gcc/gcc4x/gcc/fortran
REMOVE:kargl[202] svn merge -r 146855:146854 .
Conflict discovered in 'ChangeLog'.
Select: (p) postpone, (df) diff-full, (e) edit,
        (mc) mine-conflict, (tc) theirs-conflict,
        (s) show all options: p
--- Reverse-merging r146855 into '.':
C    ChangeLog
G    trans-io.c
U    trans-intrinsic.c
Summary of conflicts:
  Text conflicts: 1
REMOVE:kargl[203] cd ../../../obj
REMOVE:kargl[204] gmake
...
(snip)
...

/usr/home/kargl/gcc/obj/./prev-gcc/xgcc -B/usr/home/kargl/gcc/obj/.\
/prev-gcc/ -B/usr/home/kargl/work/i386-unknown-freebsd8.0/bin/ \
-B/usr/home/kargl/work/i386-unknown-freebsd8.0/bin/ -B/usr/home/kargl/work/\
i386-unknown-freebsd8.0/lib/ -isystem /usr/home/kargl/work/\
i386-unknown-freebsd8.0/include -isystem /usr/home/kargl/work/\
i386-unknown-freebsd8.0/sys-include    -c  -g -O2 -fomit-frame-pointer\
 -DIN_GCC   -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes\
 -Wcast-qual -Wold-style-definition -Wc++-compat -Wmissing-format-attribute\
 -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings\
 -Werror -fno-common  -DHAVE_CONFIG_H -I. -Ifortran -I../../gcc4x/gcc\
 -I../../gcc4x/gcc/fortran -I../../gcc4x/gcc/../include -I./../intl\
 -I../../gcc4x/gcc/../libcpp/include -I/usr/local/include\
  -I../../gcc4x/gcc/../libdecnumber -I../../gcc4x/gcc/../libdecnumber/dpd\
 -I../libdecnumber    ../../gcc4x/gcc/fortran/trans-intrinsic.c\
 -o fortran/trans-intrinsic.o
cc1: warnings being treated as errors
In file included from ../../gcc4x/gcc/fortran/trans-intrinsic.c:115:
../../gcc4x/gcc/fortran/mathbuiltins.def:32: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:32: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:32: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:32: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:43: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:43: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:43: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:43: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:44: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:44: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:44: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:44: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:45: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:45: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:45: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:45: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:46: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:46: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:46: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:46: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:47: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:47: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:47: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:47: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:48: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:48: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:48: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:48: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:49: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:49: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:49: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:49: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:50: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:50: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:50: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:50: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:51: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:51: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:51: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:51: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:52: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:52: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:52: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:52: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:53: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:53: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:53: error: enum conversion in initialization is invalid in C++
../../gcc4x/gcc/fortran/mathbuiltins.def:53: error: enum conversion in initialization is invalid in C++
gmake[3]: *** [fortran/trans-intrinsic.o] Error 1
gmake[3]: Leaving directory `/usr/home/kargl/gcc/obj/gcc'
gmake[2]: *** [all-stage2-gcc] Error 2
gmake[2]: Leaving directory `/usr/home/kargl/gcc/obj'
gmake[1]: *** [stage2-bubble] Error 2
gmake[1]: Leaving directory `/usr/home/kargl/gcc/obj'
gmake: *** [all] Error 2
REMOVE:kargl[205] exit
exit

Script done on Thu May 14 11:35:27 2009

-- 
Steve


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