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?
Started with r244292, thus GCC 7 regression.
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).
related to bug 81334 perhaps?
Created attachment 45877 [details] test-case
Unreduced test-case: https://drive.google.com/file/d/1Fp8OE7frCHNglDQ5CTGyBaQXHkeeD-vZ/view?usp=sharing
(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.
David, may I please remind you this issue?
Why this annoying note cannot be disabled using #pragma GCC diagnostic ignored "-Wmisleading-indentation" ? So only solution is -Wno-misleading-indentation?
(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?
@David: May I please remind this?
Would be nice to fix this for the last release of GCC 7.
This missed gcc 7.5 :/
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
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.
But there is no way to silence this "note".
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.
Check few lines above https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89549#c8
GCC 8.4.0 has been released, adjusting target milestone.
GCC 8 branch is being closed.
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
GCC 9 branch is being closed
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
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?))
Lewis Hyatt has been touching some code in this area recently; cc-ing...
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.
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.
GCC 10 branch is being closed.