Hi Andrew,

I know about this problem ... I guess a change of mine causes these warnings.
While I found a row of good fixes, these with ShouldNotReachHere are annoying.

What you propose has been discussed in April: 8065585: Change 
ShouldNotReachHere() to never return.
I didn't follow the discussion all to the end, but it wasn't done for some 
reason.
Also, I think, one can overrule ShoudlNotReachHere() with -XX:SuppressError=...

Best regards,
  Goetz.

-----Original Message-----
From: hotspot-dev [mailto:[email protected]] On Behalf Of 
Andrew Haley
Sent: Thursday, November 26, 2015 6:24 PM
To: build-dev <[email protected]>; hotspot-dev Source Developers 
<[email protected]>
Subject: Silence warnings with new GCC

I've been getting a lot of warnings such as

warning: 'size' may be used uninitialized in this function 
[-Wmaybe-uninitialized]

which error out with -Werror.  Almost all of them are bogus.  They are
typically of the form

    unsigned size;

    if (i->get(26, 26)) { // float
      switch(i->get(31, 30)) {
      case 0b10:
        size = 2; break;
      case 0b01:
        size = 1; break;
      case 0b00:
        size = 0; break;
      default:
        ShouldNotReachHere();
      }
    } else {
      size = i->get(31, 31);
    }

The problem here is that GCC does not know that ShouldNotReachHere()
should be treated as an unreachable statement.

The patch here fixes it.  I'd rather do this than add pointless assignments
all over the place.  Thoughts?  Opinions?

Thanks,

Andrew.



diff --git a/src/share/vm/utilities/debug.hpp b/src/share/vm/utilities/debug.hpp
--- a/src/share/vm/utilities/debug.hpp
+++ b/src/share/vm/utilities/debug.hpp
@@ -172,16 +172,24 @@
   BREAKPOINT;                                                                  
   \
 } while (0)

+#ifdef __GNUC__
+#  define UNREACHABLE __builtin_unreachable()
+#else
+#  define UNREACHABLE do { } while (0)
+#endif
+
 #define ShouldNotReachHere()                                                   
   \
 do {                                                                           
   \
   report_should_not_reach_here(__FILE__, __LINE__);                            
   \
   BREAKPOINT;                                                                  
   \
+  UNREACHABLE;                                                                 
   \
 } while (0)

 #define Unimplemented()                                                        
   \
 do {                                                                           
   \
   report_unimplemented(__FILE__, __LINE__);                                    
   \
   BREAKPOINT;                                                                  
   \
+  UNREACHABLE;                                                                 
   \
 } while (0)

 #define Untested(msg)

Reply via email to