[SERVER-29743] IDL should generate a default constructor Created: 20/Jun/17  Updated: 30/Oct/23  Resolved: 07/Aug/17

Status: Closed
Project: Core Server
Component/s: IDL
Affects Version/s: 3.5.8
Fix Version/s: 3.5.12

Type: Improvement Priority: Major - P3
Reporter: Randolph Tan Assignee: Mark Benvenuto
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-29740 Coverity analysis defect 101725: Unin... Closed
is depended on by SERVER-29741 Coverity analysis defect 101724: Unin... Closed
Duplicate
is duplicated by SERVER-29622 IDL's generated class constructors sh... Closed
Backwards Compatibility: Fully Compatible
Sprint: Platforms 2017-08-21
Participants:

 Description   

IDL code generator should generate a constructor that either:

a. Default-value (as in what is defined in the IDL) initializes all POD members or call the default constructor
b. Has arguments to initialize all member variables

This is to avoid scenarios where an instance of a idl generated class will have uninitialized member variables after construction.



 Comments   
Comment by Githook User [ 07/Aug/17 ]

Author:

{'username': 'markbenvenuto', 'email': 'mark.benvenuto@mongodb.com', 'name': 'Mark Benvenuto'}

Message: SERVER-29743 IDL generates a default constructor for primitive scalars
Branch: master
https://github.com/mongodb/mongo/commit/b85936082d4d64c5d7c270a135fe910dcaedf07d

Comment by Githook User [ 22/Jun/17 ]

Author:

{u'username': u'kaloianm', u'name': u'Kaloian Manassiev', u'email': u'kaloian.manassiev@mongodb.com'}

Message: SERVER-29743 Initialize fields with defaults in IDL

Also adds more descriptive error codes to be returned by the parser for the common error cases.
Branch: master
https://github.com/mongodb/mongo/commit/498c51d75abbbf8f5e64e4cd25f1f21bd4298bb4

Comment by Kaloian Manassiev [ 21/Jun/17 ]

While working on the write commands porting I hit an issue caused by this which resulted in a garbage value being written for boolean field:

[js_test:address] 2017-06-21T22:29:28.316+0000 c20012| 2017-06-21T22:29:28.311+0000 I NETWORK  [rsSync] invalid message: 22 invalid boolean value in element with field name 'bypassDocumentValidation' in object with unknown _id f1 0 0 0 2 63 72 65 61 74 65 49 dd 7 0 0 0 0 0 0 0 dc 0 0 0 2 69 6e 73 65 72 74 0 8 0 0 0 76 65 72 73 69 6f 6e 0 4 64 6f 63 75 6d 65 6e 74 73 0 5b 0 0 0 3 30 0 53 0 0 0 10 5f 69 64 0 1 0 0 0 10 6d 69 6e 43 6f 6d 70 61 74 69 62 6c 65 56 65 72 73 69 6f 6e 0 5 0 0 0 10 63 75 72 72 65 6e 74 56 65 72 73 69 6f 6e 0 6 0 0 0 7 63 6c 75 73 74 65 72 49 64 0 59 4a f3 48 97 b6 25 81 a4 2 5f f0 0 0 3 77 72 69 74 65 43 6f 6e 63 65 72 6e 0 1a 0 0 0 10 77 0 1 0 0 0 10 77 74 69 6d 65 6f 75 74 0 0 0 0 0 0 8 62 79 70 61 73 73 44 6f 63 75 6d 65 6e 74 56 61 6c 69 64 61 74 69 6f 6e 0 15 8 6f 72 64 65 72 65 64 0 1c 2 24 64 62 0 7 0 0 0 63 6f 6e 66 69 67 0 0

Generated at Thu Feb 08 04:21:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.