bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Error compiling bison 3.4.2 on Solaris


From: Akim Demaille
Subject: Re: Error compiling bison 3.4.2 on Solaris
Date: Sun, 20 Oct 2019 14:04:00 +0200

Hi Paul!

> Le 18 oct. 2019 à 20:51, Paul Eggert <address@hidden> a écrit :
> 
> On 10/17/19 11:34 PM, Akim Demaille wrote:
>> Bison no longer compiles cleanly (i.e., many warnings) on macOS with GCC 7, 
>> 8, 9.  Clang is ok though.  And there are similar failures on the CI with 
>> older versions of GCC.
>> https://travis-ci.org/akimd/bison/builds/599470491
> 
> First, I suggest telling Travis not to use --enable-gcc-warnings. That option 
> is intended mainly for developers, and it's not suitable for simply building 
> and testing Bison because it generates too many false alarms (as is the case 
> here).

Currently (and this is a defect), the test suite uses configure to know what 
compiler to use and what warnings it supports.  That's why I want many 
warnings: first and foremost so that the generated code has all the warnings 
enabled (and rest assured that when there's a new one that appears that we 
didn't check, I get a email from someone whose parser is hit by it.  And 
second, because it helps having maintainers environment clean :)  As is not the 
case right now: what the CI reports is exactly what I observe on my machine.

Except that on this mac GCC 7 to 9 shows the warning.  I don't understand what 
there's a difference with GNU/Linux.

> Second, the diagnostics in the above URL are all false alarms.

I don't really understand what you call them false alarms.  I agree they are 
annoying alarms, that are meant for hand-written code rather than compile-time 
metaprogramming in cpp as is the case here, but they seem legit.

This small test case

#include "intprops.h"

int main () {
  long major = 3;
  long res;
  INT_MULTIPLY_WRAPV (major, 100, &res);
}

expands to (OMG!!!)

int main () {
  long major = 3;
  long res;
  (sizeof *(&res) == sizeof (signed char) ? ((! ((__typeof__ (*(&res))) 0 < 
(__typeof__ (*(&res))) -1)) ? (((100) < 0 ? ((major) < 0 ? ((((1 ? 0 : (((1 ? 0 
: (0x7f)) + (100)))) - (1)) < 0) ? (major) < (0x7f) / (100) : 
((__builtin_sub_overflow_p (0, 100, (__typeof__ ((0) - (100))) 0) ? ((1 ? 0 : 
(100)) + (0x7f)) >> ((sizeof (100) * 8) - 1) : (0x7f) / -(100)) <= -1 - 
(major))) : __builtin_sub_overflow_p (0, ((1 ? 0 : (100)) + (
 (-0x7f - 1)
 )), (__typeof__ ((0) - (((1 ? 0 : (100)) + (
 (-0x7f - 1)
 ))))) 0) && (100) == -1 ? ((((1 ? 0 : (major)) - (1)) < 0) ? 0 < (major) + (
 (-0x7f - 1)
 ) : 0 < (major) && -1 - (
 (-0x7f - 1)
 ) < (major) - 1) : (
 (-0x7f - 1)
 ) / (100) < (major)) : (100) == 0 ? 0 : ((major) < 0 ? 
(__builtin_sub_overflow_p (0, ((1 ? 0 : (major)) + (
 (-0x7f - 1)
 )), (__typeof__ ((0) - (((1 ? 0 : (major)) + (
 (-0x7f - 1)
 ))))) 0) && (major) == -1 ? ((((1 ? 0 : (100)) - (1)) < 0) ? 0 < (100) + (
 (-0x7f - 1)
 ) : -1 - (
 (-0x7f - 1)
 ) < (100) - 1) : (
 (-0x7f - 1)
 ) / (major) < (100)) : (0x7f) / (100) < (major))) ? (*(&res) = ((signed char) 
((unsigned int) (major) * (unsigned int) (100))), 1) : (*(&res) = ((signed 
char) ((unsigned int) (major) * (unsigned int) (100))), 0)) : (((100) < 0 ? 
((major) < 0 ? ((((1 ? 0 : (((1 ? 0 : (
 (0x7f * 2 + 1)
 )) + (100)))) - (1)) < 0) ? (major) < (
 (0x7f * 2 + 1)
 ) / (100) : ((__builtin_sub_overflow_p (0, 100, (__typeof__ ((0) - (100))) 0) 
? ((1 ? 0 : (100)) + (
 (0x7f * 2 + 1)
 )) >> ((sizeof (100) * 8) - 1) : (
 (0x7f * 2 + 1)
 ) / -(100)) <= -1 - (major))) : __builtin_sub_overflow_p (0, ((1 ? 0 : (100)) 
+ (0)), (__typeof__ ((0) - (((1 ? 0 : (100)) + (0))))) 0) && (100) == -1 ? 
((((1 ? 0 : (major)) - (1)) < 0) ? 0 < (major) + (0) : 0 < (major) && -1 - (0) 
< (major) - 1) : (0) / (100) < (major)) : (100) == 0 ? 0 : ((major) < 0 ? 
(__builtin_sub_overflow_p (0, ((1 ? 0 : (major)) + (0)), (__typeof__ ((0) - 
(((1 ? 0 : (major)) + (0))))) 0) && (major) == -1 ? ((((1 ? 0 : (100)) - (1)) < 
0) ? 0 < (100) + (0) : -1 - (0) < (100) - 1) : (0) / (major) < (100)) : (
 (0x7f * 2 + 1)
 ) / (100) < (major))) ? (*(&res) = ((unsigned char) ((unsigned int) (major) * 
(unsigned int) (100))), 1) : (*(&res) = ((unsigned char) ((unsigned int) 
(major) * (unsigned int) (100))), 0))) : sizeof *(&res) == sizeof (short int) ? 
((! ((__typeof__ (*(&res))) 0 < (__typeof__ (*(&res))) -1)) ? (((100) < 0 ? 
((major) < 0 ? ((((1 ? 0 : (((1 ? 0 : (0x7fff)) + (100)))) - (1)) < 0) ? 
(major) < (0x7fff) / (100) : ((__builtin_sub_overflow_p (0, 100, (__typeof__ 
((0) - (100))) 0) ? ((1 ? 0 : (100)) + (0x7fff)) >> ((sizeof (100) * 8) - 1) : 
(0x7fff) / -(100)) <= -1 - (major))) : __builtin_sub_overflow_p (0, ((1 ? 0 : 
(100)) + (
 (-0x7fff - 1)
 )), (__typeof__ ((0) - (((1 ? 0 : (100)) + (
 (-0x7fff - 1)
 ))))) 0) && (100) == -1 ? ((((1 ? 0 : (major)) - (1)) < 0) ? 0 < (major) + (
 (-0x7fff - 1)
 ) : 0 < (major) && -1 - (
 (-0x7fff - 1)
 ) < (major) - 1) : (
 (-0x7fff - 1)
 ) / (100) < (major)) : (100) == 0 ? 0 : ((major) < 0 ? 
(__builtin_sub_overflow_p (0, ((1 ? 0 : (major)) + (
 (-0x7fff - 1)
 )), (__typeof__ ((0) - (((1 ? 0 : (major)) + (
 (-0x7fff - 1)
 ))))) 0) && (major) == -1 ? ((((1 ? 0 : (100)) - (1)) < 0) ? 0 < (100) + (
 (-0x7fff - 1)
 ) : -1 - (
 (-0x7fff - 1)
 ) < (100) - 1) : (
 (-0x7fff - 1)
 ) / (major) < (100)) : (0x7fff) / (100) < (major))) ? (*(&res) = ((short int) 
((unsigned int) (major) * (unsigned int) (100))), 1) : (*(&res) = ((short int) 
((unsigned int) (major) * (unsigned int) (100))), 0)) : (((100) < 0 ? ((major) 
< 0 ? ((((1 ? 0 : (((1 ? 0 : (
 (0x7fff * 2 + 1)
 )) + (100)))) - (1)) < 0) ? (major) < (
 (0x7fff * 2 + 1)
 ) / (100) : ((__builtin_sub_overflow_p (0, 100, (__typeof__ ((0) - (100))) 0) 
? ((1 ? 0 : (100)) + (
 (0x7fff * 2 + 1)
 )) >> ((sizeof (100) * 8) - 1) : (
 (0x7fff * 2 + 1)
 ) / -(100)) <= -1 - (major))) : __builtin_sub_overflow_p (0, ((1 ? 0 : (100)) 
+ (0)), (__typeof__ ((0) - (((1 ? 0 : (100)) + (0))))) 0) && (100) == -1 ? 
((((1 ? 0 : (major)) - (1)) < 0) ? 0 < (major) + (0) : 0 < (major) && -1 - (0) 
< (major) - 1) : (0) / (100) < (major)) : (100) == 0 ? 0 : ((major) < 0 ? 
(__builtin_sub_overflow_p (0, ((1 ? 0 : (major)) + (0)), (__typeof__ ((0) - 
(((1 ? 0 : (major)) + (0))))) 0) && (major) == -1 ? ((((1 ? 0 : (100)) - (1)) < 
0) ? 0 < (100) + (0) : -1 - (0) < (100) - 1) : (0) / (major) < (100)) : (
 (0x7fff * 2 + 1)
 ) / (100) < (major))) ? (*(&res) = ((unsigned short int) ((unsigned int) 
(major) * (unsigned int) (100))), 1) : (*(&res) = ((unsigned short int) 
((unsigned int) (major) * (unsigned int) (100))), 0))) : sizeof *(&res) == 
sizeof (int) ? ((((1 ? 0 : (*(&res))) - (1)) < 0) ? (((100) < 0 ? ((major) < 0 
? ((((1 ? 0 : (((1 ? 0 : (0x7fffffff)) + (100)))) - (1)) < 0) ? (major) < 
(0x7fffffff) / (100) : ((__builtin_sub_overflow_p (0, 100, (__typeof__ ((0) - 
(100))) 0) ? ((1 ? 0 : (100)) + (0x7fffffff)) >> ((sizeof (100) * 8) - 1) : 
(0x7fffffff) / -(100)) <= -1 - (major))) : __builtin_sub_overflow_p (0, ((1 ? 0 
: (100)) + (
 (-0x7fffffff - 1)
 )), (__typeof__ ((0) - (((1 ? 0 : (100)) + (
 (-0x7fffffff - 1)
 ))))) 0) && (100) == -1 ? ((((1 ? 0 : (major)) - (1)) < 0) ? 0 < (major) + (
 (-0x7fffffff - 1)
 ) : 0 < (major) && -1 - (
 (-0x7fffffff - 1)
 ) < (major) - 1) : (
 (-0x7fffffff - 1)
 ) / (100) < (major)) : (100) == 0 ? 0 : ((major) < 0 ? 
(__builtin_sub_overflow_p (0, ((1 ? 0 : (major)) + (
 (-0x7fffffff - 1)
 )), (__typeof__ ((0) - (((1 ? 0 : (major)) + (
 (-0x7fffffff - 1)
 ))))) 0) && (major) == -1 ? ((((1 ? 0 : (100)) - (1)) < 0) ? 0 < (100) + (
 (-0x7fffffff - 1)
 ) : -1 - (
 (-0x7fffffff - 1)
 ) < (100) - 1) : (
 (-0x7fffffff - 1)
 ) / (major) < (100)) : (0x7fffffff) / (100) < (major))) ? (*(&res) = ((int) 
((unsigned int) (major) * (unsigned int) (100))), 1) : (*(&res) = ((int) 
((unsigned int) (major) * (unsigned int) (100))), 0)) : (((100) < 0 ? ((major) 
< 0 ? ((((1 ? 0 : (((1 ? 0 : (
 (0x7fffffff * 2U + 1U)
 )) + (100)))) - (1)) < 0) ? (major) < (
 (0x7fffffff * 2U + 1U)
 ) / (100) : ((__builtin_sub_overflow_p (0, 100, (__typeof__ ((0) - (100))) 0) 
? ((1 ? 0 : (100)) + (
 (0x7fffffff * 2U + 1U)
 )) >> ((sizeof (100) * 8) - 1) : (
 (0x7fffffff * 2U + 1U)
 ) / -(100)) <= -1 - (major))) : __builtin_sub_overflow_p (0, ((1 ? 0 : (100)) 
+ (0)), (__typeof__ ((0) - (((1 ? 0 : (100)) + (0))))) 0) && (100) == -1 ? 
((((1 ? 0 : (major)) - (1)) < 0) ? 0 < (major) + (0) : 0 < (major) && -1 - (0) 
< (major) - 1) : (0) / (100) < (major)) : (100) == 0 ? 0 : ((major) < 0 ? 
(__builtin_sub_overflow_p (0, ((1 ? 0 : (major)) + (0)), (__typeof__ ((0) - 
(((1 ? 0 : (major)) + (0))))) 0) && (major) == -1 ? ((((1 ? 0 : (100)) - (1)) < 
0) ? 0 < (100) + (0) : -1 - (0) < (100) - 1) : (0) / (major) < (100)) : (
 (0x7fffffff * 2U + 1U)
 ) / (100) < (major))) ? (*(&res) = ((unsigned int) ((unsigned int) (major) * 
(unsigned int) (100))), 1) : (*(&res) = ((unsigned int) ((unsigned int) (major) 
* (unsigned int) (100))), 0))) : (sizeof *(&res) == sizeof (long int) ? ((((1 ? 
0 : (*(&res))) - (1)) < 0) ? (((100) < 0 ? ((major) < 0 ? ((((1 ? 0 : (((1 ? 0 
: (0x7fffffffffffffffL)) + (100)))) - (1)) < 0) ? (major) < 
(0x7fffffffffffffffL) / (100) : ((__builtin_sub_overflow_p (0, 100, (__typeof__ 
((0) - (100))) 0) ? ((1 ? 0 : (100)) + (0x7fffffffffffffffL)) >> ((sizeof (100) 
* 8) - 1) : (0x7fffffffffffffffL) / -(100)) <= -1 - (major))) : 
__builtin_sub_overflow_p (0, ((1 ? 0 : (100)) + (
 (-0x7fffffffffffffffL - 1L)
 )), (__typeof__ ((0) - (((1 ? 0 : (100)) + (
 (-0x7fffffffffffffffL - 1L)
 ))))) 0) && (100) == -1 ? ((((1 ? 0 : (major)) - (1)) < 0) ? 0 < (major) + (
 (-0x7fffffffffffffffL - 1L)
 ) : 0 < (major) && -1 - (
 (-0x7fffffffffffffffL - 1L)
 ) < (major) - 1) : (
 (-0x7fffffffffffffffL - 1L)
 ) / (100) < (major)) : (100) == 0 ? 0 : ((major) < 0 ? 
(__builtin_sub_overflow_p (0, ((1 ? 0 : (major)) + (
 (-0x7fffffffffffffffL - 1L)
 )), (__typeof__ ((0) - (((1 ? 0 : (major)) + (
 (-0x7fffffffffffffffL - 1L)
 ))))) 0) && (major) == -1 ? ((((1 ? 0 : (100)) - (1)) < 0) ? 0 < (100) + (
 (-0x7fffffffffffffffL - 1L)
 ) : -1 - (
 (-0x7fffffffffffffffL - 1L)
 ) < (100) - 1) : (
 (-0x7fffffffffffffffL - 1L)
 ) / (major) < (100)) : (0x7fffffffffffffffL) / (100) < (major))) ? (*(&res) = 
((long int) ((unsigned long int) (major) * (unsigned long int) (100))), 1) : 
(*(&res) = ((long int) ((unsigned long int) (major) * (unsigned long int) 
(100))), 0)) : (((100) < 0 ? ((major) < 0 ? ((((1 ? 0 : (((1 ? 0 : (
 (0x7fffffffffffffffL * 2UL + 1UL)
 )) + (100)))) - (1)) < 0) ? (major) < (
 (0x7fffffffffffffffL * 2UL + 1UL)
 ) / (100) : ((__builtin_sub_overflow_p (0, 100, (__typeof__ ((0) - (100))) 0) 
? ((1 ? 0 : (100)) + (
 (0x7fffffffffffffffL * 2UL + 1UL)
 )) >> ((sizeof (100) * 8) - 1) : (
 (0x7fffffffffffffffL * 2UL + 1UL)
 ) / -(100)) <= -1 - (major))) : __builtin_sub_overflow_p (0, ((1 ? 0 : (100)) 
+ (0)), (__typeof__ ((0) - (((1 ? 0 : (100)) + (0))))) 0) && (100) == -1 ? 
((((1 ? 0 : (major)) - (1)) < 0) ? 0 < (major) + (0) : 0 < (major) && -1 - (0) 
< (major) - 1) : (0) / (100) < (major)) : (100) == 0 ? 0 : ((major) < 0 ? 
(__builtin_sub_overflow_p (0, ((1 ? 0 : (major)) + (0)), (__typeof__ ((0) - 
(((1 ? 0 : (major)) + (0))))) 0) && (major) == -1 ? ((((1 ? 0 : (100)) - (1)) < 
0) ? 0 < (100) + (0) : -1 - (0) < (100) - 1) : (0) / (major) < (100)) : (
 (0x7fffffffffffffffL * 2UL + 1UL)
 ) / (100) < (major))) ? (*(&res) = ((unsigned long int) ((unsigned long int) 
(major) * (unsigned long int) (100))), 1) : (*(&res) = ((unsigned long int) 
((unsigned long int) (major) * (unsigned long int) (100))), 0))) : ((((1 ? 0 : 
(*(&res))) - (1)) < 0) ? (((100) < 0 ? ((major) < 0 ? ((((1 ? 0 : (((1 ? 0 : 
(0x7fffffffffffffffLL)) + (100)))) - (1)) < 0) ? (major) < 
(0x7fffffffffffffffLL) / (100) : ((__builtin_sub_overflow_p (0, 100, 
(__typeof__ ((0) - (100))) 0) ? ((1 ? 0 : (100)) + (0x7fffffffffffffffLL)) >> 
((sizeof (100) * 8) - 1) : (0x7fffffffffffffffLL) / -(100)) <= -1 - (major))) : 
__builtin_sub_overflow_p (0, ((1 ? 0 : (100)) + (
 (-0x7fffffffffffffffLL - 1LL)
 )), (__typeof__ ((0) - (((1 ? 0 : (100)) + (
 (-0x7fffffffffffffffLL - 1LL)
 ))))) 0) && (100) == -1 ? ((((1 ? 0 : (major)) - (1)) < 0) ? 0 < (major) + (
 (-0x7fffffffffffffffLL - 1LL)
 ) : 0 < (major) && -1 - (
 (-0x7fffffffffffffffLL - 1LL)
 ) < (major) - 1) : (
 (-0x7fffffffffffffffLL - 1LL)
 ) / (100) < (major)) : (100) == 0 ? 0 : ((major) < 0 ? 
(__builtin_sub_overflow_p (0, ((1 ? 0 : (major)) + (
 (-0x7fffffffffffffffLL - 1LL)
 )), (__typeof__ ((0) - (((1 ? 0 : (major)) + (
 (-0x7fffffffffffffffLL - 1LL)
 ))))) 0) && (major) == -1 ? ((((1 ? 0 : (100)) - (1)) < 0) ? 0 < (100) + (
 (-0x7fffffffffffffffLL - 1LL)
 ) : -1 - (
 (-0x7fffffffffffffffLL - 1LL)
 ) < (100) - 1) : (
 (-0x7fffffffffffffffLL - 1LL)
 ) / (major) < (100)) : (0x7fffffffffffffffLL) / (100) < (major))) ? (*(&res) = 
((long long int) ((unsigned long long int) (major) * (unsigned long long int) 
(100))), 1) : (*(&res) = ((long long int) ((unsigned long long int) (major) * 
(unsigned long long int) (100))), 0)) : (((100) < 0 ? ((major) < 0 ? ((((1 ? 0 
: (((1 ? 0 : (
 (0x7fffffffffffffffLL * 2ULL + 1ULL)
 )) + (100)))) - (1)) < 0) ? (major) < (
 (0x7fffffffffffffffLL * 2ULL + 1ULL)
 ) / (100) : ((__builtin_sub_overflow_p (0, 100, (__typeof__ ((0) - (100))) 0) 
? ((1 ? 0 : (100)) + (
 (0x7fffffffffffffffLL * 2ULL + 1ULL)
 )) >> ((sizeof (100) * 8) - 1) : (
 (0x7fffffffffffffffLL * 2ULL + 1ULL)
 ) / -(100)) <= -1 - (major))) : __builtin_sub_overflow_p (0, ((1 ? 0 : (100)) 
+ (0)), (__typeof__ ((0) - (((1 ? 0 : (100)) + (0))))) 0) && (100) == -1 ? 
((((1 ? 0 : (major)) - (1)) < 0) ? 0 < (major) + (0) : 0 < (major) && -1 - (0) 
< (major) - 1) : (0) / (100) < (major)) : (100) == 0 ? 0 : ((major) < 0 ? 
(__builtin_sub_overflow_p (0, ((1 ? 0 : (major)) + (0)), (__typeof__ ((0) - 
(((1 ? 0 : (major)) + (0))))) 0) && (major) == -1 ? ((((1 ? 0 : (100)) - (1)) < 
0) ? 0 < (100) + (0) : -1 - (0) < (100) - 1) : (0) / (major) < (100)) : (
 (0x7fffffffffffffffLL * 2ULL + 1ULL)
 ) / (100) < (major))) ? (*(&res) = ((unsigned long long int) ((unsigned long 
long int) (major) * (unsigned long long int) (100))), 1) : (*(&res) = 
((unsigned long long int) ((unsigned long long int) (major) * (unsigned long 
long int) (100))), 0)))));
}

GCC9 -Wextra says:

> gcc-mp-9 -Wextra foo.i
> foo.i: In function 'main':
> foo.i:86:23: warning: comparison of unsigned expression < 0 is always false 
> [-Wtype-limits]
>    86 |  )) + (100)))) - (1)) < 0) ? (major) < (
>       |                       ^
> foo.i:116:23: warning: comparison of unsigned expression < 0 is always false 
> [-Wtype-limits]
>   116 |  )) + (100)))) - (1)) < 0) ? (major) < (
>       |                       ^
> foo.i:124:12: warning: comparison of integer expressions of different 
> signedness: 'long unsigned int' and 'long int' [-Wsign-compare]
>   124 |  ) / (100) < (major))) ? (*(&res) = ((unsigned long int) ((unsigned 
> long int) (major) * (unsigned long int) (100))), 1) : (*(&res) = ((unsigned 
> long int) ((unsigned long int) (major) * (unsigned long int) (100))), 0))) : 
> ((((1 ? 0 : (*(&res))) - (1)) < 0) ? (((100) < 0 ? ((major) < 0 ? ((((1 ? 0 : 
> (((1 ? 0 : (0x7fffffffffffffffLL)) + (100)))) - (1)) < 0) ? (major) < 
> (0x7fffffffffffffffLL) / (100) : ((__builtin_sub_overflow_p (0, 100, 
> (__typeof__ ((0) - (100))) 0) ? ((1 ? 0 : (100)) + (0x7fffffffffffffffLL)) >> 
> ((sizeof (100) * 8) - 1) : (0x7fffffffffffffffLL) / -(100)) <= -1 - (major))) 
> : __builtin_sub_overflow_p (0, ((1 ? 0 : (100)) + (
>       |            ^
> foo.i:146:23: warning: comparison of unsigned expression < 0 is always false 
> [-Wtype-limits]
>   146 |  )) + (100)))) - (1)) < 0) ? (major) < (
>       |                       ^

If we focus on the first warning, it can be reduced to

  (((1 ? 0 : ((1 ? 0 : 0x7fffffff * 2U + 1U) + 100)) - 1) < 0)
    ? 42 : 51;

or

  (((1 ? 0 : (1 ? 0 : 1U)) - 1) < 0)
    ? 42 : 51;

Now we agree that if the compiler is *required* to compute the result when it 
can *and* to use the type of the result, it should get 0, a signed int.  But 
that's not my understanding of standard C, where usual promotions are used to 
compute the type "common" to both branches of the ternary operator.  Which is 
unsigned here.

I wanted to make sure what the compiler thought the types are, and I have:

int main() {
  long major = 100;
  (((1 ? 0 : (1 ? 0 : 1U)) - 1) < 0)
    ? 42 : 51;

  typeof(((1 ? 0 : (1 ? 0 : 1U)) - 1)) x = "foo";

  typeof(0) y = "foo";

  typeof(1 ? 0 : 42U) z = "foo";

  typeof(1 ? 42U : 0) w = "foo";
}


which gives

> gcc-mp-9 -Wextra bar.c
> bar.c: In function 'main':
> bar.c:3:33: warning: comparison of unsigned expression < 0 is always false 
> [-Wtype-limits]
>     3 |   (((1 ? 0 : (1 ? 0 : 1U)) - 1) < 0)
>       |                                 ^
> bar.c:6:44: warning: initialization of 'unsigned int' from 'char *' makes 
> integer from pointer without a cast [-Wint-conversion]
>     6 |   typeof(((1 ? 0 : (1 ? 0 : 1U)) - 1)) x = "foo";
>       |                                            ^~~~~
> bar.c:8:17: warning: initialization of 'int' from 'char *' makes integer from 
> pointer without a cast [-Wint-conversion]
>     8 |   typeof(0) y = "foo";
>       |                 ^~~~~
> bar.c:10:27: warning: initialization of 'unsigned int' from 'char *' makes 
> integer from pointer without a cast [-Wint-conversion]
>    10 |   typeof(1 ? 0 : 42U) z = "foo";
>       |                           ^~~~~
> bar.c:12:27: warning: initialization of 'unsigned int' from 'char *' makes 
> integer from pointer without a cast [-Wint-conversion]
>    12 |   typeof(1 ? 42U : 0) w = "foo";
>       |                           ^~~~~


So I still believe the warning is valid.  Annoying, but valid.  And therefore I 
would prefer to have intprops.h use pragmas to disable it locally.

But of course we can disable the warning for bison, and not the test suite, as 
below.  It fixes the issues with GCC, but not yet with old clangs (3.3 and 3.4).

I'll address them later.

Cheers!



commit e31f92495ce14a5d924b148c8ea1470003cc47c1
Author: Akim Demaille <address@hidden>
Date:   Sun Oct 20 08:55:44 2019 +0200

    build: disable -Wtype-limits, except in the test suite
    
    The current implementation of lib/intprops.h results in "unsigned < 0"
    comparisons, which triggers warnings.  See
    
    https://lists.gnu.org/archive/html/bug-bison/2019-10/msg00061.html
    
    * configure.ac (warn_common): Disable -Wtype-limits.
    (warn_tests): Restore it.

diff --git a/configure.ac b/configure.ac
index 0c1efde1..f055a68c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -94,9 +94,10 @@ AC_ARG_ENABLE([gcc-warnings],
               [enable_gcc_warnings=no])
 AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
 if test "$enable_gcc_warnings" = yes; then
-  warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align
+  warn_common='-Wall -Wextra -Wcast-align
     -fparse-all-comments -Wdocumentation
     -Wformat -Wimplicit-fallthrough -Wnull-dereference
+    -Wno-sign-compare -Wno-type-limits
     -Wpointer-arith -Wshadow
     -Wwrite-strings'
   warn_c='-Wbad-function-cast -Wstrict-prototypes'
@@ -111,7 +112,7 @@ if test "$enable_gcc_warnings" = yes; then
   # trick in the test suite to check some private implementation
   # details for lalr1.cc.
   warn_tests='-Wundef -pedantic -Wconversion
-    -Wdeprecated -Wsign-compare -Wsign-conversion
+    -Wdeprecated -Wsign-compare -Wsign-conversion -Wtype-limits
     -fno-color-diagnostics
     -Wno-keyword-macro'
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]