Spurious error on bypassing initialization of trivially constructible objects

XMLWordPrintable

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Low
    • Code Generation Tools
    • CODEGEN-3951
    • Hide
      ARM_18.1.0.LTS
      MSP430_18.1.0.LTS
      MSP430_20.2.0.LTS
      ARM_18.12.0.LTS
      MSP430_21.6.0.LTS
      MSP430_18.12.0.LTS
      ARM_20.2.0.LTS
      Show
      ARM_18.1.0.LTS MSP430_18.1.0.LTS MSP430_20.2.0.LTS ARM_18.12.0.LTS MSP430_21.6.0.LTS MSP430_18.12.0.LTS ARM_20.2.0.LTS

      In the following source code, the marked lines cause spurious errors about bypassing the initialization of an object.
      However, the standard allows certain constructs, such as classes with trivial constructors, nonstatic member functions, and objects which contain or inherit from them to be bypassed since initialization is considered trivial.

      struct trivial_struct { };
      struct struct_with_member_fn { int b()

      { return 2; } };

      struct inherits_trivial_default_ctor : trivial_struct { };
      struct inherits_nonstatic_member_fn : struct_with_member_fn { };
      struct contains_trivial_default_member { inherits_trivial_default_ctor a; };
      struct all_of_the_above : trivial_struct {
      trivial_struct a;
      int b() { return 2; }

      };

      extern int n;

      int main()
      {

      { if(n<2) goto La; inherits_trivial_default_ctor a; La: n++; }

      // Error

      { if(n<2) goto Lb; inherits_nonstatic_member_fn b; Lb: n++; }

      // Error

      { if(n<2) goto Lc; contains_trivial_default_member c; Lc: n++; }

      // Error

      { if(n<2) goto Ld; all_of_the_above d; Ld: n++; }

      // Error
      }

            Assignee:
            TI User
            Reporter:
            TI User
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:

                Connection: Intermediate to External PROD System
                EXTSYNC-1069 - Spurious error on bypassing initial...
                SYNCHRONIZED
                • Last Sync Date: