Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stale TODO/Proto-rules #811

Open
cubbimew opened this issue Dec 11, 2016 · 3 comments
Open

Stale TODO/Proto-rules #811

cubbimew opened this issue Dec 11, 2016 · 3 comments
Assignees

Comments

@cubbimew
Copy link
Member

cubbimew commented Dec 11, 2016

A number of entries in the To-do: Unclassified proto-rules are addressed in the main text:

I believe all these should be dropped and the rest converted to open github issues (if it's unclear whether a rule should exist) or stub rules (if it's clear the rule should exist, but the details are not ready).

@AndrewPardoe
Copy link
Contributor

Sergey, we agree that this set of suggestions is up to your usual standard of quality. Could you please make these edits?

@hsutter
Copy link
Contributor

hsutter commented May 8, 2017

I'd suggest these (small) ones for .8:

  • flag virtual calls in ctors/dtors
  • don't use bind, use lambdas instead (yes, you can move-capture -- there's no capture by && but there is [x = std::move(x)])
  • use RAII lock guards, never call .lock/.unlock directly

I'd suggest these for either .8 or post-.8:

  • avoid implicit conversions
  • const => thread-safe
  • avoid void* parameters and return values
  • use const wherever possible
  • use auto (note in C++17, we can remove the "almost" from "almost always auto"...)
  • static vs dynamic polymorphism
  • avoid private inheritance, prefer private membership
  • don't use recursive mutexes -- refactor to avoid the need for a nested transaction, or if you can't then at least pass a unique_lock instead to show that you did lock
  • never use atomic_compare_exchange_strong<UDT> -- NOTE that because you should use _strong when doing a single test (if) and _weak for a loop which retries anyway, this also argues that you should not use atomic_compare_exchange_***<UDT> except in a retry loop (do not use it with a single if test)
  • individual shared_ptr and shared_future objects should be synchronized like any old object if they are shared

We aim to cover these via lifetime rules:

  • leaks from temporaries
  • pointer/iterator invalidation

I'd suggest abandoning the following:

  • long-distance friendship
  • physical design (this is changing with modules anyway)
  • using directives in global scope (these are okay in .cpp files after the last #include)
  • namespace granularity
  • inline namespaces (unless we have guidance? I don't)
  • never pass a pointer down the call stack (why not? we should recommend passing pointers rather than smart pointers)

@cubbimew
Copy link
Member Author

cubbimew commented Jun 4, 2017

There are currently 35 entries in the To-do section.

Dropping 5 out of 6 suggested to be dropped by Herb (using directives is already covered by SF.6), dropping the 2 entries covered by lifetime rules, and dropping 11 of the issues already covered by existing rules/issues as noted in the first comment, I believe we're actually down to these 14

  • Namespaces
    already in as a stub rule SF.20
  • Const member functions should be thread safe
  • Don't overabstract
  • falling through a function bottom
  • static vs dynamic polymorphism
  • lambdas vs classes
    this one is actually already stated in F.50 fairly explicitly
  • prefer lambdas to std::bind
  • LSP
  • private inheritance vs/and membership
  • avoid static class members variables (race conditions, almost-global variables)
    this one is actually already mentioned in CP.2's enforcement section
  • don't use recursive mutexes
  • don't use atomic_compare_exchange_strong<UDT>
  • shared_future and shared_ptr objects should be synchronized if shared
  • rules for arithmetic
    these are now covered ES.100 - ES.107

Of these (minus 4 that appear to be covered), the following 7 seem concrete enough to make rules:

  • Const member functions should be thread safe
  • falling through a function bottom
  • prefer lambdas to std::bind
  • don't use recursive mutexes
  • don't use atomic_compare_exchange_strong<UDT>
  • shared_future and shared_ptr objects should be synchronized if shared
  • private inheritance vs/and membership

and the following 3 seem philosophical and non-enforceable

  • Don't overabstract
  • static vs dynamic polymorphism
  • LSP

shall I go ahead with creating 10 github issues for these and dropping the To-do section entirely?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants