Bug 89549 - [11/12/13/14/15 Regression] -Wmisleading-indentation is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers
Summary: [11/12/13/14/15 Regression] -Wmisleading-indentation is disabled from this po...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 9.0
: P2 normal
Target Milestone: 11.5
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2019-03-01 15:25 UTC by Martin Liška
Modified: 2024-04-26 10:35 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work: 6.4.0
Known to fail: 7.4.0, 8.3.0, 9.0
Last reconfirmed: 2019-06-05 00:00:00


Attachments
test-case (1.29 KB, text/plain)
2019-03-04 08:39 UTC, Martin Liška
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Liška 2019-03-01 15:25:08 UTC
Seen on a test-case that is not having many lines, but one line is very wide:

$ cat mi.ii
                                                              class String {               public:                                              bool operator==(char *) const;      bool operator!=(char *) ;                                                                                                                                                                                                                                                                                 String() ;     String(char *);     };
      class StringName {     public:                                     StringName(char *);         };
             template <class a> class List {    public:   void push_back( a ) ; };
         class Variant { public:  enum b {   NIL}  ;               };
      enum c {  PROPERTY_HINT_NONE};
      enum {                  PROPERTY_USAGE_CATEGORY                                };
      struct PropertyInfo {                       PropertyInfo(Variant::b , String , c ,  String , int )  ;     };
            class Object {     protected:    static String _get_category() ;    void  _set() ;  bool _get( StringName , Variant ) const ;  void _get_property_list(List<PropertyInfo> *) const ;  void _notification();                   static void _get_valid_parents_static(List<String> *)                    ;     bool _is_gpl_reversed() const                                                                                                                       ;                             };
                       class ClassDB {  public:  template <class >  void _add_class() ;              static void get_property_list(StringName , List<PropertyInfo> *, bool , const Object * );                                                               };
      class d : public Object {     protected:  static void _bind_methods(); };
                       class AudioStreamPlayback : public d {    public:    static String get_class_static() ;   bool is_class( String ) const ; bool is_class_ptr(void *) const ; static void *_get_bind_methods() ; static void initialize_class() ; bool (Object::*_get_get() const)(const StringName &, Variant &) const ; bool _getv( StringName , Variant ) const ;  bool (Object::*_get_set() )(const StringName &, const Variant &) ; bool _setv( StringName ,  Variant ) ;  void (Object::*_get_get_property_list() const)(List<PropertyInfo> * ) const ; void _get_property_listv(List<PropertyInfo> *, bool ) const ;    };
         String get_category_static_category ;
   class AudioStreamPlaybackRandomPitch : public AudioStreamPlayback {  private:  mutable StringName _class_name; friend class ClassDB; public:   static inline void *get_class_ptr_static() { static int ptr; return &ptr; } static inline String get_class_static() { return String("AudioStreamPlaybackRandomPitch"); } static inline String get_parent_class_static() { return AudioStreamPlayback::get_class_static(); } static void get_inheritance_list_static(List<String> *p_inheritance_list) { AudioStreamPlayback:get_inheritance_list_static(p_inheritance_list); p_inheritance_list->push_back(String("AudioStreamPlaybackRandomPitch")); } static String get_category_static() {  if (_get_category != AudioStreamPlayback::_get_category) { if (get_category_static_category != "") get_category_static_category = ""; get_category_static_category = _get_category(); } return get_category_static_category; } static String inherits_static() { return String("AudioStreamPlayback"); } virtual bool is_class(const String p_class) const { return (p_class == ("AudioStreamPlaybackRandomPitch")) ? true : AudioStreamPlayback::is_class(p_class); } virtual bool is_class_ptr(void *p_ptr) const { return (p_ptr == get_class_ptr_static) ? true : AudioStreamPlayback::is_class_ptr(p_ptr); } static void get_valid_parents_static(List<String> *p_parents) { if (AudioStreamPlaybackRandomPitch::_get_valid_parents_static != AudioStreamPlayback::_get_valid_parents_static) { AudioStreamPlaybackRandomPitch:_get_valid_parents_static(p_parents); } AudioStreamPlayback:get_valid_parents_static(p_parents); } protected: inline static void (*_get_bind_methods())() { return AudioStreamPlaybackRandomPitch::_bind_methods; } public: static void initialize_class() { static bool initialized = false; if (initialized) return AudioStreamPlayback::initialize_class(); ClassDB::_add_class<AudioStreamPlaybackRandomPitch>; if (AudioStreamPlaybackRandomPitch::_get_bind_methods != AudioStreamPlayback::_get_bind_methods()) _bind_methods; initialized = true; } protected: virtual void _initialize_classv() { initialize_class; } inline bool (Object::*_get_get() const)(const StringName &p_name, Variant &) const { return (bool (Object::*)(const StringName &, Variant &) const) & AudioStreamPlaybackRandomPitch::_get; } virtual bool _getv(const StringName p_name, Variant &r_ret) const { if (AudioStreamPlaybackRandomPitch::_get_get() != AudioStreamPlayback::_get_get()) { if (_get(p_name, r_ret)) return true; } return AudioStreamPlayback::_getv(p_name, r_ret); } inline bool (Object::*_get_set() const)(const StringName &p_name, const Variant &p_property) { return (bool (Object::*)(const StringName &, const Variant &)) & AudioStreamPlaybackRandomPitch::_set; } virtual bool _setv(const StringName &p_name, const Variant &p_property) { if (AudioStreamPlayback::_setv(p_name, p_property)) return true; if (AudioStreamPlaybackRandomPitch::_get_set() != AudioStreamPlayback::_get_set())  return false; } inline void (Object::*_get_get_property_list() const)(List<PropertyInfo> * p_list) const { return (void (Object::*)(List<PropertyInfo> *) const) & AudioStreamPlaybackRandomPitch::_get_property_list; } virtual void _get_property_listv(List<PropertyInfo> *p_list, bool p_reversed) const { if (!p_reversed) { AudioStreamPlayback::_get_property_listv(p_list, p_reversed); } p_list->push_back(PropertyInfo(Variant::NIL, get_class_static(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY)); if (!_is_gpl_reversed()) ClassDB::get_property_list("AudioStreamPlaybackRandomPitch", p_list, true, this); if (AudioStreamPlaybackRandomPitch::_get_get_property_list() != AudioStreamPlayback::_get_get_property_list()) { _get_property_list(p_list); } if (_is_gpl_reversed()) ClassDB::get_property_list("AudioStreamPlaybackRandomPitch", p_list, true, this); if (p_reversed) { AudioStreamPlayback::_get_property_listv(p_list, p_reversed); } } inline void (Object::*_get_notification() const)(int) { return (void (Object::*)(int)) & AudioStreamPlaybackRandomPitch::_notification; } virtual void _notificationv(int p_notification, bool p_reversed) { if (p_reversed) ;       p_reversed; }    };

$ g++ mi.ii -c -Wmisleading-indentation
...
mi.ii: In member function ‘virtual void AudioStreamPlaybackRandomPitch::_notificationv(int, bool)’:
mi.ii:13: note: -Wmisleading-indentation is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers
    class AudioStreamPlaybackRandomPitch : public AudioStreamPlayback {  private:  mutable StringName _class_name; friend class ClassDB; public:   static inline void *get_class_ptr_static() { static int ptr; return &ptr; } static inline String get_class_static() { return String("AudioStreamPlaybackRandomPitch"); } static inline String get_parent_class_static() { return AudioStreamPlayback::get_class_static(); } static void get_inheritance_list_static(List<String> *p_inheritance_list) { AudioStreamPlayback:get_inheritance_list_static(p_inheritance_list); p_inheritance_list->push_back(String("AudioStreamPlaybackRandomPitch")); } static String get_category_static() {  if (_get_category != AudioStreamPlayback::_get_category) { if (get_category_static_category != "") get_category_static_category = ""; get_category_static_category = _get_category(); } return get_category_static_category; } static String inherits_static() { return String("AudioStreamPlayback"); } virtual bool is_class(const String p_class) const { return (p_class == ("AudioStreamPlaybackRandomPitch")) ? true : AudioStreamPlayback::is_class(p_class); } virtual bool is_class_ptr(void *p_ptr) const { return (p_ptr == get_class_ptr_static) ? true : AudioStreamPlayback::is_class_ptr(p_ptr); } static void get_valid_parents_static(List<String> *p_parents) { if (AudioStreamPlaybackRandomPitch::_get_valid_parents_static != AudioStreamPlayback::_get_valid_parents_static) { AudioStreamPlaybackRandomPitch:_get_valid_parents_static(p_parents); } AudioStreamPlayback:get_valid_parents_static(p_parents); } protected: inline static void (*_get_bind_methods())() { return AudioStreamPlaybackRandomPitch::_bind_methods; } public: static void initialize_class() { static bool initialized = false; if (initialized) return AudioStreamPlayback::initialize_class(); ClassDB::_add_class<AudioStreamPlaybackRandomPitch>; if (AudioStreamPlaybackRandomPitch::_get_bind_methods != AudioStreamPlayback::_get_bind_methods()) _bind_methods; initialized = true; } protected: virtual void _initialize_classv() { initialize_class; } inline bool (Object::*_get_get() const)(const StringName &p_name, Variant &) const { return (bool (Object::*)(const StringName &, Variant &) const) & AudioStreamPlaybackRandomPitch::_get; } virtual bool _getv(const StringName p_name, Variant &r_ret) const { if (AudioStreamPlaybackRandomPitch::_get_get() != AudioStreamPlayback::_get_get()) { if (_get(p_name, r_ret)) return true; } return AudioStreamPlayback::_getv(p_name, r_ret); } inline bool (Object::*_get_set() const)(const StringName &p_name, const Variant &p_property) { return (bool (Object::*)(const StringName &, const Variant &)) & AudioStreamPlaybackRandomPitch::_set; } virtual bool _setv(const StringName &p_name, const Variant &p_property) { if (AudioStreamPlayback::_setv(p_name, p_property)) return true; if (AudioStreamPlaybackRandomPitch::_get_set() != AudioStreamPlayback::_get_set())  return false; } inline void (Object::*_get_get_property_list() const)(List<PropertyInfo> * p_list) const { return (void (Object::*)(List<PropertyInfo> *) const) & AudioStreamPlaybackRandomPitch::_get_property_list; } virtual void _get_property_listv(List<PropertyInfo> *p_list, bool p_reversed) const { if (!p_reversed) { AudioStreamPlayback::_get_property_listv(p_list, p_reversed); } p_list->push_back(PropertyInfo(Variant::NIL, get_class_static(), PROPERTY_HINT_NONE, String(), PROPERTY_USAGE_CATEGORY)); if (!_is_gpl_reversed()) ClassDB::get_property_list("AudioStreamPlaybackRandomPitch", p_list, true, this); if (AudioStreamPlaybackRandomPitch::_get_get_property_list() != AudioStreamPlayback::_get_get_property_list()) { _get_property_list(p_list); } if (_is_gpl_reversed()) ClassDB::get_property_list("AudioStreamPlaybackRandomPitch", p_list, true, this); if (p_reversed) { AudioStreamPlayback::_get_property_listv(p_list, p_reversed); } } inline void (Object::*_get_notification() const)(int) { return (void (Object::*)(int)) & AudioStreamPlaybackRandomPitch::_notification; } virtual void _notificationv(int p_notification, bool p_reversed) { if (p_reversed) ;       p_reversed; }    };

It's probably related to line map and it's capacity. But can we do better here?
Comment 1 Martin Liška 2019-03-01 15:28:13 UTC
Started with r244292, thus GCC 7 regression.
Comment 2 David Malcolm 2019-03-01 21:53:30 UTC
Can you attach the testcase please, rather than pasting it as a comment.  I can't reproduce the note from the example, but whitespace is significant here, and I'm not sure roundtripping through a BZ comment has preserved it.  Thanks.

That said, it looks like it's giving up, due to a line wider than > LINE_MAP_MAX_COLUMN_NUMBER; the note doesn't seem to consider that case (rather the case of running out of location_t values).
Comment 3 Eric Gallager 2019-03-02 01:25:28 UTC
related to bug 81334 perhaps?
Comment 4 Martin Liška 2019-03-04 08:39:26 UTC
Created attachment 45877 [details]
test-case
Comment 5 Martin Liška 2019-03-04 08:39:59 UTC
Unreduced test-case:
https://drive.google.com/file/d/1Fp8OE7frCHNglDQ5CTGyBaQXHkeeD-vZ/view?usp=sharing
Comment 6 David Malcolm 2019-03-05 14:50:57 UTC
(In reply to Martin Liška from comment #4)
> Created attachment 45877 [details]
> test-case

Thanks; I'm able to see the behavior with that.
Comment 7 Martin Liška 2019-06-05 08:59:21 UTC
David, may I please remind you this issue?
Comment 8 Dávid Bolvanský 2019-08-01 16:09:04 UTC
Why this annoying note cannot be disabled using 
#pragma GCC diagnostic ignored "-Wmisleading-indentation" ?

So only solution is -Wno-misleading-indentation?
Comment 9 Eric Gallager 2019-08-04 18:12:27 UTC
(In reply to Dávid Bolvanský from comment #8)
> Why this annoying note cannot be disabled using 
> #pragma GCC diagnostic ignored "-Wmisleading-indentation" ?

When a note associated with a warning can't be disabled with a pragma, that usually means that someone forgot to check the return value of the warning() call in GCC before calling inform(), but I dunno if that's the case here... 

> 
> So only solution is -Wno-misleading-indentation?
Comment 10 Martin Liška 2019-08-27 14:08:56 UTC
@David: May I please remind this?
Comment 11 Dávid Bolvanský 2019-09-06 12:50:26 UTC
Would be nice to fix this for the last release of GCC 7.
Comment 12 Dávid Bolvanský 2019-11-05 09:13:07 UTC
This missed gcc 7.5 :/
Comment 13 Richard Biener 2019-11-14 07:51:17 UTC
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
Comment 14 Jakub Jelinek 2019-11-25 18:56:46 UTC
I don't see a bug here, it behaves as expected, once you have too long line somewhere or too many lines, column tracking is disabled and column tracking is essential for this warning:
  /* PR c++/68819: if the column number is zero, we presumably
     had a location_t > LINE_MAP_MAX_LOCATION_WITH_COLS, and so
     we have no column information.
     Act as if no conversion was possible, triggering the
     error-handling path in the caller.  */
  if (!exploc.column)
    {
      static bool issued_note = false;
      if (!issued_note)
        {
          /* Notify the user the first time this happens.  */
          issued_note = true;
          inform (loc,
                  "%<-Wmisleading-indentation%> is disabled from this point"
                  " onwards, since column-tracking was disabled due to"
                  " the size of the code/headers");
        }
      return false;
    }
This isn't a note that is related to some particular warning, just a message telling that there won't be any further warnings emitted due to this later.
Comment 15 Dávid Bolvanský 2019-11-25 19:14:23 UTC
But there is no way to silence this "note".
Comment 16 Jakub Jelinek 2019-11-25 20:00:46 UTC
Of course there is, -Wno-misleading-indentation or use line breaks from time to time.  With >= 4KB long lines, the user clearly doesn't care about indentation, so the warning doesn't make sense.
Comment 17 Dávid Bolvanský 2019-11-25 20:14:35 UTC
Check few lines above

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89549#c8
Comment 18 Jakub Jelinek 2020-03-04 09:33:09 UTC
GCC 8.4.0 has been released, adjusting target milestone.
Comment 19 Jakub Jelinek 2021-05-14 09:51:21 UTC
GCC 8 branch is being closed.
Comment 20 Richard Biener 2021-06-01 08:13:15 UTC
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
Comment 21 Richard Biener 2022-05-27 09:40:21 UTC
GCC 9 branch is being closed
Comment 22 Jakub Jelinek 2022-06-28 10:36:52 UTC
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Comment 23 David Blaikie 2022-09-08 19:09:33 UTC
FWIW, the inability to disable this note has caused Clang to disable the warning due to the noise. ( https://reviews.llvm.org/D132914 )

It'd be nice to have a way to enable the warning as "best effort" - knowing that some files are too long to get checking.

(but also - it'd be nice if the warning were implemented in such a way that it could scale up to indefinitely long files - it seems like that should be possible to have a scalable implementation of the warning? (at least a version that's linear in the number of lines in the file/or the number of lines in long nested scopes?))
Comment 24 Eric Gallager 2022-10-09 07:24:21 UTC
Lewis Hyatt has been touching some code in this area recently; cc-ing...
Comment 25 Lewis Hyatt 2022-10-10 14:34:07 UTC
This patch would make the note controllable via #pragma GCC diagnostic in the same way as the warning is:

=====
diff --git a/gcc/c-family/c-indentation.cc b/gcc/c-family/c-indentation.cc
index 85a3ae1b303..3b5d3b17cc9 100644
--- a/gcc/c-family/c-indentation.cc
+++ b/gcc/c-family/c-indentation.cc
@@ -310,7 +310,8 @@ should_warn_for_misleading_indentation (const token_indent_info &guard_tinfo,
   if (!guard_exploc.column || !body_exploc.column || !next_stmt_exploc.column)
     {
       static bool issued_note = false;
-      if (!issued_note)
+      if (!issued_note
+         && warning_enabled_at (guard_loc, OPT_Wmisleading_indentation))
        {
          /* Notify the user the first time this happens.  */
          issued_note = true;

=====

I am not quite sure how to interpret Jakub's comments though (comment 14 and comment 16)... not sure whether he was saying this change would be undesirable, or just explaining why it doesn't seem strictly necessary.
Comment 26 David Blaikie 2022-10-10 18:09:10 UTC
FWIW I'm not sure it's a pragma I'd want, but it might be sufficient (put the pragma at the start of very long/autogenerated files) - I'd have thought what some folks (myself/LLVM included, I think) is a version of the warning that is "best effort" and otherwise quiet.

"Tell me when you know I have misleading indentation, otherwise say nothing" - which is how most warnings work, basically - they all have false negatives.
Comment 27 Richard Biener 2023-07-07 10:34:57 UTC
GCC 10 branch is being closed.